mirror of
https://github.com/friendica/friendica
synced 2025-04-25 10:30:12 +00:00
renamed Logger::setLogger() to Logger::init()
This commit is contained in:
parent
80f1feabe5
commit
e1d9d67632
12 changed files with 276 additions and 92 deletions
|
@ -29,8 +29,7 @@ interface IConfigAdapter
|
|||
public function get($cat, $key);
|
||||
|
||||
/**
|
||||
* Stores a config value ($value) in the category ($family) under the key ($key)
|
||||
* for the user_id $uid.
|
||||
* Stores a config value ($value) in the category ($family) under the key ($key).
|
||||
*
|
||||
* Note: Please do not store booleans - convert to 0/1 integer values!
|
||||
*
|
||||
|
@ -59,4 +58,14 @@ interface IConfigAdapter
|
|||
* @return bool
|
||||
*/
|
||||
public function isConnected();
|
||||
|
||||
/**
|
||||
* Checks, if a config value ($value) in the category ($cat) is already loaded.
|
||||
*
|
||||
* @param string $cat The configuration category
|
||||
* @param string $key The configuration key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLoaded($cat, $key);
|
||||
}
|
||||
|
|
|
@ -69,4 +69,15 @@ interface IPConfigAdapter
|
|||
* @return bool
|
||||
*/
|
||||
public function isConnected();
|
||||
|
||||
/**
|
||||
* Checks, if a config value ($value) in the category ($cat) is already loaded for the user_id $uid.
|
||||
*
|
||||
* @param string $uid The user_id
|
||||
* @param string $cat The configuration category
|
||||
* @param string $key The configuration key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLoaded($uid, $cat, $key);
|
||||
}
|
||||
|
|
|
@ -120,4 +120,16 @@ class JITConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAdapte
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isLoaded($cat, $key)
|
||||
{
|
||||
if (!$this->isConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (isset($this->in_db[$cat][$key])) && $this->in_db[$cat][$key];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ class JITPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfigAdap
|
|||
}
|
||||
} else if ($cat != 'config') {
|
||||
// Negative caching
|
||||
$return[null] = "!<unset>!";
|
||||
$return = "!<unset>!";
|
||||
}
|
||||
DBA::close($pconfigs);
|
||||
|
||||
|
@ -123,4 +123,16 @@ class JITPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfigAdap
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isLoaded($uid, $cat, $key)
|
||||
{
|
||||
if (!$this->isConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (isset($this->in_db[$uid][$cat][$key])) && $this->in_db[$uid][$cat][$key];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,13 +32,13 @@ class PreloadConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAd
|
|||
|
||||
$configs = DBA::select('config', ['cat', 'v', 'k']);
|
||||
while ($config = DBA::fetch($configs)) {
|
||||
$return[$config['k']] = $config['v'];
|
||||
$return[$config['cat']][$config['k']] = $config['v'];
|
||||
}
|
||||
DBA::close($configs);
|
||||
|
||||
$this->config_loaded = true;
|
||||
|
||||
return [$cat => $return];
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,4 +101,16 @@ class PreloadConfigAdapter extends AbstractDbaConfigAdapter implements IConfigAd
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isLoaded($cat, $key)
|
||||
{
|
||||
if (!$this->isConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->config_loaded;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,13 +44,13 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
|
|||
|
||||
$pconfigs = DBA::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
|
||||
while ($pconfig = DBA::fetch($pconfigs)) {
|
||||
$return[$pconfig['k']] = $pconfig['v'];
|
||||
$return[$pconfig['cat']][$pconfig['k']] = $pconfig['v'];
|
||||
}
|
||||
DBA::close($pconfigs);
|
||||
|
||||
$this->config_loaded = true;
|
||||
|
||||
return [$cat => $return];
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,4 +123,16 @@ class PreloadPConfigAdapter extends AbstractDbaConfigAdapter implements IPConfig
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isLoaded($uid, $cat, $key)
|
||||
{
|
||||
if (!$this->isConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->config_loaded;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,22 +79,20 @@ class Configuration
|
|||
*/
|
||||
public function get($cat, $key, $default_value = null, $refresh = false)
|
||||
{
|
||||
// Return the value of the cache if found and no refresh is forced
|
||||
if (!$refresh && $this->configCache->has($cat, $key)) {
|
||||
// if the value isn't loaded or refresh is needed, load it to the cache
|
||||
if ($this->configAdapter->isConnected() &&
|
||||
(!$this->configAdapter->isLoaded($cat, $key) ||
|
||||
$refresh)) {
|
||||
$dbvalue = $this->configAdapter->get($cat, $key);
|
||||
|
||||
if ($dbvalue !== '!<unset>!') {
|
||||
$this->configCache->set($cat, $key, $dbvalue);
|
||||
}
|
||||
}
|
||||
|
||||
// use the config cache for return
|
||||
if ($this->configCache->has($cat, $key)) {
|
||||
return $this->configCache->get($cat, $key);
|
||||
}
|
||||
|
||||
// if we don't find the value in the cache and the adapter isn't ready, return the default value
|
||||
if (!$this->configAdapter->isConnected()) {
|
||||
return $default_value;
|
||||
}
|
||||
|
||||
// load DB value to cache
|
||||
$dbvalue = $this->configAdapter->get($cat, $key);
|
||||
|
||||
if ($dbvalue !== '!<unset>!') {
|
||||
$this->configCache->set($cat, $key, $dbvalue);
|
||||
return $dbvalue;
|
||||
} else {
|
||||
return $default_value;
|
||||
}
|
||||
|
|
|
@ -71,22 +71,20 @@ class PConfiguration
|
|||
*/
|
||||
public function get($uid, $cat, $key, $default_value = null, $refresh = false)
|
||||
{
|
||||
// Return the value of the cache if found and no refresh is forced
|
||||
if (!$refresh && $this->configCache->hasP($uid, $cat, $key)) {
|
||||
// if the value isn't loaded or refresh is needed, load it to the cache
|
||||
if ($this->configAdapter->isConnected() &&
|
||||
(!$this->configAdapter->isLoaded($uid, $cat, $key) ||
|
||||
$refresh)) {
|
||||
$dbValue = $this->configAdapter->get($uid, $cat, $key);
|
||||
|
||||
if ($dbValue !== '!<unset>!') {
|
||||
$this->configCache->setP($uid, $cat, $key, $dbValue);
|
||||
}
|
||||
}
|
||||
|
||||
// use the config cache for return
|
||||
if ($this->configCache->hasP($uid, $cat, $key)) {
|
||||
return $this->configCache->getP($uid, $cat, $key);
|
||||
}
|
||||
|
||||
// if we don't find the value in the cache and the adapter isn't ready, return the default value
|
||||
if (!$this->configAdapter->isConnected()) {
|
||||
return $default_value;
|
||||
}
|
||||
|
||||
// load DB value to cache
|
||||
$dbvalue = $this->configAdapter->get($uid, $cat, $key);
|
||||
|
||||
if ($dbvalue !== '!<unset>!') {
|
||||
$this->configCache->setP($uid, $cat, $key, $dbvalue);
|
||||
return $dbvalue;
|
||||
} else {
|
||||
return $default_value;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ class Logger extends BaseObject
|
|||
*
|
||||
* @param LoggerInterface $logger The Logger instance of this Application
|
||||
*/
|
||||
public static function setLogger($logger)
|
||||
public static function init($logger)
|
||||
{
|
||||
self::$logger = $logger;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class LoggerFactory
|
|||
static::addStreamHandler($logger, $stream, $loglevel);
|
||||
}
|
||||
|
||||
Logger::setLogger($logger);
|
||||
Logger::init($logger);
|
||||
|
||||
return $logger;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue