mirror of
https://github.com/friendica/friendica
synced 2024-11-11 11:42:53 +00:00
Updating type-hints and some naming conventions
This commit is contained in:
parent
1c51d7d22f
commit
d78ac57514
9 changed files with 74 additions and 74 deletions
|
@ -32,7 +32,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @param Config\IConfigCache $config The configuration cache
|
* @param Config\IConfigCache $config The configuration cache
|
||||||
*/
|
*/
|
||||||
public static function init($config)
|
public static function init(Config\IConfigCache $config)
|
||||||
{
|
{
|
||||||
self::$config = $config;
|
self::$config = $config;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @param Config\IConfigAdapter $adapter
|
* @param Config\IConfigAdapter $adapter
|
||||||
*/
|
*/
|
||||||
public static function setAdapter($adapter)
|
public static function setAdapter(Config\IConfigAdapter $adapter)
|
||||||
{
|
{
|
||||||
self::$adapter = $adapter;
|
self::$adapter = $adapter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
||||||
/**
|
/**
|
||||||
* @param array $config A initial config array
|
* @param array $config A initial config array
|
||||||
*/
|
*/
|
||||||
public function __construct($config = [])
|
public function __construct(array $config = [])
|
||||||
{
|
{
|
||||||
$this->config = [];
|
$this->config = [];
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
||||||
foreach ($config as $category => $values) {
|
foreach ($config as $category => $values) {
|
||||||
foreach ($values as $key => $value) {
|
foreach ($values as $key => $value) {
|
||||||
if ($overwrite) {
|
if ($overwrite) {
|
||||||
self::set($category, $key, $value);
|
$this->set($category, $key, $value);
|
||||||
} else {
|
} else {
|
||||||
self::setDefault($category, $key, $value);
|
$this->setDefault($category, $key, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
||||||
private function setDefault($cat, $k, $v)
|
private function setDefault($cat, $k, $v)
|
||||||
{
|
{
|
||||||
if (!isset($this->config[$cat][$k])) {
|
if (!isset($this->config[$cat][$k])) {
|
||||||
self::set($cat, $k, $v);
|
$this->set($cat, $k, $v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class ConfigCacheLoader
|
||||||
* The addon sub-directory
|
* The addon sub-directory
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const ADDONSDIRECTORY = '/addons/';
|
const ADDONDIRECTORY = '/addon/';
|
||||||
|
|
||||||
private $baseDir;
|
private $baseDir;
|
||||||
private $configDir;
|
private $configDir;
|
||||||
|
@ -141,7 +141,7 @@ class ConfigCacheLoader
|
||||||
public function loadConfigFile($filename, $addon = false)
|
public function loadConfigFile($filename, $addon = false)
|
||||||
{
|
{
|
||||||
if ($addon) {
|
if ($addon) {
|
||||||
$filepath = $this->baseDir . self::ADDONSDIRECTORY . $filename . self::SUBDIRECTORY . $filename . ".config.php";
|
$filepath = $this->baseDir . self::ADDONDIRECTORY . $filename . self::SUBDIRECTORY . $filename . ".config.php";
|
||||||
} else {
|
} else {
|
||||||
$filepath = $this->configDir . $filename . ".config.php";
|
$filepath = $this->configDir . $filename . ".config.php";
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,14 @@ class JITConfigAdapter implements IConfigAdapter
|
||||||
/**
|
/**
|
||||||
* @var IConfigCache The config cache of this driver
|
* @var IConfigCache The config cache of this driver
|
||||||
*/
|
*/
|
||||||
private $config;
|
private $configCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IConfigCache $config The config cache of this driver
|
* @param IConfigCache $configCache The config cache of this driver
|
||||||
*/
|
*/
|
||||||
public function __construct($config)
|
public function __construct(IConfigCache $configCache)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->configCache = $configCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load($cat = "config")
|
public function load($cat = "config")
|
||||||
|
@ -40,7 +40,7 @@ class JITConfigAdapter implements IConfigAdapter
|
||||||
while ($config = DBA::fetch($configs)) {
|
while ($config = DBA::fetch($configs)) {
|
||||||
$k = $config['k'];
|
$k = $config['k'];
|
||||||
|
|
||||||
$this->config->set($cat, $k, $config['v']);
|
$this->configCache->set($cat, $k, $config['v']);
|
||||||
|
|
||||||
if ($cat !== 'config') {
|
if ($cat !== 'config') {
|
||||||
$this->cache[$cat][$k] = $config['v'];
|
$this->cache[$cat][$k] = $config['v'];
|
||||||
|
@ -72,18 +72,18 @@ class JITConfigAdapter implements IConfigAdapter
|
||||||
$this->cache[$cat][$k] = $value;
|
$this->cache[$cat][$k] = $value;
|
||||||
$this->in_db[$cat][$k] = true;
|
$this->in_db[$cat][$k] = true;
|
||||||
return $value;
|
return $value;
|
||||||
} elseif ($this->config->get($cat, $k) !== null) {
|
} elseif ($this->configCache->get($cat, $k) !== null) {
|
||||||
// Assign the value (mostly) from config/local.config.php file to the cache
|
// Assign the value (mostly) from config/local.config.php file to the cache
|
||||||
$this->cache[$cat][$k] = $this->config->get($cat, $k);
|
$this->cache[$cat][$k] = $this->configCache->get($cat, $k);
|
||||||
$this->in_db[$cat][$k] = false;
|
$this->in_db[$cat][$k] = false;
|
||||||
|
|
||||||
return $this->config->get($cat, $k);
|
return $this->configCache->get($cat, $k);
|
||||||
} elseif ($this->config->get('config', $k) !== null) {
|
} elseif ($this->configCache->get('config', $k) !== null) {
|
||||||
// Assign the value (mostly) from config/local.config.php file to the cache
|
// Assign the value (mostly) from config/local.config.php file to the cache
|
||||||
$this->cache[$k] = $this->config->get('config', $k);
|
$this->cache[$k] = $this->configCache->get('config', $k);
|
||||||
$this->in_db[$k] = false;
|
$this->in_db[$k] = false;
|
||||||
|
|
||||||
return $this->config->get('config', $k);
|
return $this->configCache->get('config', $k);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cache[$cat][$k] = '!<unset>!';
|
$this->cache[$cat][$k] = '!<unset>!';
|
||||||
|
@ -112,7 +112,7 @@ class JITConfigAdapter implements IConfigAdapter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config->set($cat, $k, $value);
|
$this->configCache->set($cat, $k, $value);
|
||||||
|
|
||||||
// Assign the just added value to the cache
|
// Assign the just added value to the cache
|
||||||
$this->cache[$cat][$k] = $dbvalue;
|
$this->cache[$cat][$k] = $dbvalue;
|
||||||
|
|
|
@ -18,14 +18,14 @@ class JITPConfigAdapter implements IPConfigAdapter
|
||||||
* The config cache of this adapter
|
* The config cache of this adapter
|
||||||
* @var IPConfigCache
|
* @var IPConfigCache
|
||||||
*/
|
*/
|
||||||
private $config;
|
private $configCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IPConfigCache $config The config cache of this adapter
|
* @param IPConfigCache $configCache The config cache of this adapter
|
||||||
*/
|
*/
|
||||||
public function __construct($config)
|
public function __construct(IPConfigCache $configCache)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->configCache = $configCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load($uid, $cat)
|
public function load($uid, $cat)
|
||||||
|
@ -35,13 +35,13 @@ class JITPConfigAdapter implements IPConfigAdapter
|
||||||
while ($pconfig = DBA::fetch($pconfigs)) {
|
while ($pconfig = DBA::fetch($pconfigs)) {
|
||||||
$k = $pconfig['k'];
|
$k = $pconfig['k'];
|
||||||
|
|
||||||
$this->config->setP($uid, $cat, $k, $pconfig['v']);
|
$this->configCache->setP($uid, $cat, $k, $pconfig['v']);
|
||||||
|
|
||||||
$this->in_db[$uid][$cat][$k] = true;
|
$this->in_db[$uid][$cat][$k] = true;
|
||||||
}
|
}
|
||||||
} else if ($cat != 'config') {
|
} else if ($cat != 'config') {
|
||||||
// Negative caching
|
// Negative caching
|
||||||
$this->config->setP($uid, $cat, null, "!<unset>!");
|
$this->configCache->setP($uid, $cat, null, "!<unset>!");
|
||||||
}
|
}
|
||||||
DBA::close($pconfigs);
|
DBA::close($pconfigs);
|
||||||
}
|
}
|
||||||
|
@ -50,17 +50,17 @@ class JITPConfigAdapter implements IPConfigAdapter
|
||||||
{
|
{
|
||||||
if (!$refresh) {
|
if (!$refresh) {
|
||||||
// Looking if the whole family isn't set
|
// Looking if the whole family isn't set
|
||||||
if ($this->config->getP($uid, $cat) !== null) {
|
if ($this->configCache->getP($uid, $cat) !== null) {
|
||||||
if ($this->config->getP($uid, $cat) === '!<unset>!') {
|
if ($this->configCache->getP($uid, $cat) === '!<unset>!') {
|
||||||
return $default_value;
|
return $default_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->config->getP($uid, $cat, $k) !== null) {
|
if ($this->configCache->getP($uid, $cat, $k) !== null) {
|
||||||
if ($this->config->getP($uid, $cat, $k) === '!<unset>!') {
|
if ($this->configCache->getP($uid, $cat, $k) === '!<unset>!') {
|
||||||
return $default_value;
|
return $default_value;
|
||||||
}
|
}
|
||||||
return $this->config->getP($uid, $cat, $k);
|
return $this->configCache->getP($uid, $cat, $k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,13 +68,13 @@ class JITPConfigAdapter implements IPConfigAdapter
|
||||||
if (DBA::isResult($pconfig)) {
|
if (DBA::isResult($pconfig)) {
|
||||||
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $pconfig['v']) ? unserialize($pconfig['v']) : $pconfig['v']);
|
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $pconfig['v']) ? unserialize($pconfig['v']) : $pconfig['v']);
|
||||||
|
|
||||||
$this->config->setP($uid, $cat, $k, $val);
|
$this->configCache->setP($uid, $cat, $k, $val);
|
||||||
|
|
||||||
$this->in_db[$uid][$cat][$k] = true;
|
$this->in_db[$uid][$cat][$k] = true;
|
||||||
|
|
||||||
return $val;
|
return $val;
|
||||||
} else {
|
} else {
|
||||||
$this->config->setP($uid, $cat, $k, '!<unset>!');
|
$this->configCache->setP($uid, $cat, $k, '!<unset>!');
|
||||||
|
|
||||||
$this->in_db[$uid][$cat][$k] = false;
|
$this->in_db[$uid][$cat][$k] = false;
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ class JITPConfigAdapter implements IPConfigAdapter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config->setP($uid, $cat, $k, $value);
|
$this->configCache->setP($uid, $cat, $k, $value);
|
||||||
|
|
||||||
// manage array value
|
// manage array value
|
||||||
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
||||||
|
@ -111,7 +111,7 @@ class JITPConfigAdapter implements IPConfigAdapter
|
||||||
|
|
||||||
public function delete($uid, $cat, $k)
|
public function delete($uid, $cat, $k)
|
||||||
{
|
{
|
||||||
$this->config->deleteP($uid, $cat, $k);
|
$this->configCache->deleteP($uid, $cat, $k);
|
||||||
|
|
||||||
if (!empty($this->in_db[$uid][$cat][$k])) {
|
if (!empty($this->in_db[$uid][$cat][$k])) {
|
||||||
unset($this->in_db[$uid][$cat][$k]);
|
unset($this->in_db[$uid][$cat][$k]);
|
||||||
|
|
|
@ -19,14 +19,14 @@ class PreloadConfigAdapter implements IConfigAdapter
|
||||||
/**
|
/**
|
||||||
* @var IConfigCache The config cache of this driver
|
* @var IConfigCache The config cache of this driver
|
||||||
*/
|
*/
|
||||||
private $config;
|
private $configCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IConfigCache $config The config cache of this driver
|
* @param IConfigCache $configCache The config cache of this driver
|
||||||
*/
|
*/
|
||||||
public function __construct($config)
|
public function __construct(IConfigCache $configCache)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->configCache = $configCache;
|
||||||
$this->load();
|
$this->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class PreloadConfigAdapter implements IConfigAdapter
|
||||||
|
|
||||||
$configs = DBA::select('config', ['cat', 'v', 'k']);
|
$configs = DBA::select('config', ['cat', 'v', 'k']);
|
||||||
while ($config = DBA::fetch($configs)) {
|
while ($config = DBA::fetch($configs)) {
|
||||||
$this->config->set($config['cat'], $config['k'], $config['v']);
|
$this->configCache->set($config['cat'], $config['k'], $config['v']);
|
||||||
}
|
}
|
||||||
DBA::close($configs);
|
DBA::close($configs);
|
||||||
|
|
||||||
|
@ -50,11 +50,11 @@ class PreloadConfigAdapter implements IConfigAdapter
|
||||||
if ($refresh) {
|
if ($refresh) {
|
||||||
$config = DBA::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
|
$config = DBA::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
|
||||||
if (DBA::isResult($config)) {
|
if (DBA::isResult($config)) {
|
||||||
$this->config->set($cat, $k, $config['v']);
|
$this->configCache->set($cat, $k, $config['v']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = $this->config->get($cat, $k, $default_value);
|
$return = $this->configCache->get($cat, $k, $default_value);
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -66,11 +66,11 @@ class PreloadConfigAdapter implements IConfigAdapter
|
||||||
// The exception are array values.
|
// The exception are array values.
|
||||||
$compare_value = !is_array($value) ? (string)$value : $value;
|
$compare_value = !is_array($value) ? (string)$value : $value;
|
||||||
|
|
||||||
if ($this->config->get($cat, $k) === $compare_value) {
|
if ($this->configCache->get($cat, $k) === $compare_value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config->set($cat, $k, $value);
|
$this->configCache->set($cat, $k, $value);
|
||||||
|
|
||||||
// manage array value
|
// manage array value
|
||||||
$dbvalue = is_array($value) ? serialize($value) : $value;
|
$dbvalue = is_array($value) ? serialize($value) : $value;
|
||||||
|
@ -85,7 +85,7 @@ class PreloadConfigAdapter implements IConfigAdapter
|
||||||
|
|
||||||
public function delete($cat, $k)
|
public function delete($cat, $k)
|
||||||
{
|
{
|
||||||
$this->config->delete($cat, $k);
|
$this->configCache->delete($cat, $k);
|
||||||
|
|
||||||
$result = DBA::delete('config', ['cat' => $cat, 'k' => $k]);
|
$result = DBA::delete('config', ['cat' => $cat, 'k' => $k]);
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,15 @@ class PreloadPConfigAdapter implements IPConfigAdapter
|
||||||
* The config cache of this adapter
|
* The config cache of this adapter
|
||||||
* @var IPConfigCache
|
* @var IPConfigCache
|
||||||
*/
|
*/
|
||||||
private $config;
|
private $configCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IPConfigCache $config The config cache of this adapter
|
* @param IPConfigCache $configCache The config cache of this adapter
|
||||||
* @param int $uid The UID of the current user
|
* @param int $uid The UID of the current user
|
||||||
*/
|
*/
|
||||||
public function __construct($config, $uid = null)
|
public function __construct(IPConfigCache $configCache, $uid = null)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->configCache = $configCache;
|
||||||
if (isset($uid)) {
|
if (isset($uid)) {
|
||||||
$this->load($uid, 'config');
|
$this->load($uid, 'config');
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class PreloadPConfigAdapter implements IPConfigAdapter
|
||||||
|
|
||||||
$pconfigs = DBA::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
|
$pconfigs = DBA::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
|
||||||
while ($pconfig = DBA::fetch($pconfigs)) {
|
while ($pconfig = DBA::fetch($pconfigs)) {
|
||||||
$this->config->setP($uid, $pconfig['cat'], $pconfig['k'], $pconfig['v']);
|
$this->configCache->setP($uid, $pconfig['cat'], $pconfig['k'], $pconfig['v']);
|
||||||
}
|
}
|
||||||
DBA::close($pconfigs);
|
DBA::close($pconfigs);
|
||||||
|
|
||||||
|
@ -62,13 +62,13 @@ class PreloadPConfigAdapter implements IPConfigAdapter
|
||||||
if ($refresh) {
|
if ($refresh) {
|
||||||
$config = DBA::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
|
$config = DBA::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
|
||||||
if (DBA::isResult($config)) {
|
if (DBA::isResult($config)) {
|
||||||
$this->config->setP($uid, $cat, $k, $config['v']);
|
$this->configCache->setP($uid, $cat, $k, $config['v']);
|
||||||
} else {
|
} else {
|
||||||
$this->config->deleteP($uid, $cat, $k);
|
$this->configCache->deleteP($uid, $cat, $k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->config->getP($uid, $cat, $k, $default_value);;
|
return $this->configCache->getP($uid, $cat, $k, $default_value);;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set($uid, $cat, $k, $value)
|
public function set($uid, $cat, $k, $value)
|
||||||
|
@ -81,11 +81,11 @@ class PreloadPConfigAdapter implements IPConfigAdapter
|
||||||
// The exception are array values.
|
// The exception are array values.
|
||||||
$compare_value = !is_array($value) ? (string)$value : $value;
|
$compare_value = !is_array($value) ? (string)$value : $value;
|
||||||
|
|
||||||
if ($this->config->getP($uid, $cat, $k) === $compare_value) {
|
if ($this->configCache->getP($uid, $cat, $k) === $compare_value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config->setP($uid, $cat, $k, $value);
|
$this->configCache->setP($uid, $cat, $k, $value);
|
||||||
|
|
||||||
// manage array value
|
// manage array value
|
||||||
$dbvalue = is_array($value) ? serialize($value) : $value;
|
$dbvalue = is_array($value) ? serialize($value) : $value;
|
||||||
|
@ -104,7 +104,7 @@ class PreloadPConfigAdapter implements IPConfigAdapter
|
||||||
$this->load($uid, $cat);
|
$this->load($uid, $cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config->deleteP($uid, $cat, $k);
|
$this->configCache->deleteP($uid, $cat, $k);
|
||||||
|
|
||||||
$result = DBA::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
|
$result = DBA::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class DBA
|
||||||
/**
|
/**
|
||||||
* @var IConfigCache
|
* @var IConfigCache
|
||||||
*/
|
*/
|
||||||
private static $config;
|
private static $configCache;
|
||||||
private static $server_info = '';
|
private static $server_info = '';
|
||||||
private static $connection;
|
private static $connection;
|
||||||
private static $driver;
|
private static $driver;
|
||||||
|
@ -50,14 +50,14 @@ class DBA
|
||||||
private static $db_name = '';
|
private static $db_name = '';
|
||||||
private static $db_charset = '';
|
private static $db_charset = '';
|
||||||
|
|
||||||
public static function connect($config, $serveraddr, $user, $pass, $db, $charset = null)
|
public static function connect($configCache, $serveraddr, $user, $pass, $db, $charset = null)
|
||||||
{
|
{
|
||||||
if (!is_null(self::$connection) && self::connected()) {
|
if (!is_null(self::$connection) && self::connected()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are storing these values for being able to perform a reconnect
|
// We are storing these values for being able to perform a reconnect
|
||||||
self::$config = $config;
|
self::$configCache = $configCache;
|
||||||
self::$db_serveraddr = $serveraddr;
|
self::$db_serveraddr = $serveraddr;
|
||||||
self::$db_user = $user;
|
self::$db_user = $user;
|
||||||
self::$db_pass = $pass;
|
self::$db_pass = $pass;
|
||||||
|
@ -158,7 +158,7 @@ class DBA
|
||||||
public static function reconnect() {
|
public static function reconnect() {
|
||||||
self::disconnect();
|
self::disconnect();
|
||||||
|
|
||||||
$ret = self::connect(self::$config, self::$db_serveraddr, self::$db_user, self::$db_pass, self::$db_name, self::$db_charset);
|
$ret = self::connect(self::$configCache, self::$db_serveraddr, self::$db_user, self::$db_pass, self::$db_name, self::$db_charset);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ class DBA
|
||||||
*/
|
*/
|
||||||
private static function logIndex($query) {
|
private static function logIndex($query) {
|
||||||
|
|
||||||
if (!self::$config->get('system', 'db_log_index')) {
|
if (!self::$configCache->get('system', 'db_log_index')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,18 +232,18 @@ class DBA
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$watchlist = explode(',', self::$config->get('system', 'db_log_index_watch'));
|
$watchlist = explode(',', self::$configCache->get('system', 'db_log_index_watch'));
|
||||||
$blacklist = explode(',', self::$config->get('system', 'db_log_index_blacklist'));
|
$blacklist = explode(',', self::$configCache->get('system', 'db_log_index_blacklist'));
|
||||||
|
|
||||||
while ($row = self::fetch($r)) {
|
while ($row = self::fetch($r)) {
|
||||||
if ((intval(self::$config->get('system', 'db_loglimit_index')) > 0)) {
|
if ((intval(self::$configCache->get('system', 'db_loglimit_index')) > 0)) {
|
||||||
$log = (in_array($row['key'], $watchlist) &&
|
$log = (in_array($row['key'], $watchlist) &&
|
||||||
($row['rows'] >= intval(self::$config->get('system', 'db_loglimit_index'))));
|
($row['rows'] >= intval(self::$configCache->get('system', 'db_loglimit_index'))));
|
||||||
} else {
|
} else {
|
||||||
$log = false;
|
$log = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((intval(self::$config->get('system', 'db_loglimit_index_high')) > 0) && ($row['rows'] >= intval($Config::getConfigValue('system', 'db_loglimit_index_high')))) {
|
if ((intval(self::$configCache->get('system', 'db_loglimit_index_high')) > 0) && ($row['rows'] >= intval(self::$configCache->get('system', 'db_loglimit_index_high')))) {
|
||||||
$log = true;
|
$log = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ class DBA
|
||||||
|
|
||||||
if ($log) {
|
if ($log) {
|
||||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
@file_put_contents(self::$config->get('system', 'db_log_index'), DateTimeFormat::utcNow()."\t".
|
@file_put_contents(self::$configCache->get('system', 'db_log_index'), DateTimeFormat::utcNow()."\t".
|
||||||
$row['key']."\t".$row['rows']."\t".$row['Extra']."\t".
|
$row['key']."\t".$row['rows']."\t".$row['Extra']."\t".
|
||||||
basename($backtrace[1]["file"])."\t".
|
basename($backtrace[1]["file"])."\t".
|
||||||
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
|
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
|
||||||
|
@ -423,7 +423,7 @@ class DBA
|
||||||
|
|
||||||
$orig_sql = $sql;
|
$orig_sql = $sql;
|
||||||
|
|
||||||
if (self::$config->get('system', 'db_callstack') !== null) {
|
if (self::$configCache->get('system', 'db_callstack') !== null) {
|
||||||
$sql = "/*".System::callstack()." */ ".$sql;
|
$sql = "/*".System::callstack()." */ ".$sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,15 +584,15 @@ class DBA
|
||||||
|
|
||||||
$a->saveTimestamp($stamp1, 'database');
|
$a->saveTimestamp($stamp1, 'database');
|
||||||
|
|
||||||
if (self::$config->get('system', 'db_log')) {
|
if (self::$configCache->get('system', 'db_log')) {
|
||||||
$stamp2 = microtime(true);
|
$stamp2 = microtime(true);
|
||||||
$duration = (float)($stamp2 - $stamp1);
|
$duration = (float)($stamp2 - $stamp1);
|
||||||
|
|
||||||
if (($duration > self::$config->get('system', 'db_loglimit'))) {
|
if (($duration > self::$configCache->get('system', 'db_loglimit'))) {
|
||||||
$duration = round($duration, 3);
|
$duration = round($duration, 3);
|
||||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
|
||||||
@file_put_contents(self::$config->get('system', 'db_log'), DateTimeFormat::utcNow()."\t".$duration."\t".
|
@file_put_contents(self::$configCache->get('system', 'db_log'), DateTimeFormat::utcNow()."\t".$duration."\t".
|
||||||
basename($backtrace[1]["file"])."\t".
|
basename($backtrace[1]["file"])."\t".
|
||||||
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
|
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
|
||||||
substr(self::replaceParameters($sql, $args), 0, 2000)."\n", FILE_APPEND);
|
substr(self::replaceParameters($sql, $args), 0, 2000)."\n", FILE_APPEND);
|
||||||
|
@ -1031,7 +1031,7 @@ class DBA
|
||||||
* This process must only be started once, since the value is cached.
|
* This process must only be started once, since the value is cached.
|
||||||
*/
|
*/
|
||||||
private static function buildRelationData() {
|
private static function buildRelationData() {
|
||||||
$definition = DBStructure::definition(self::$config->get('system', 'basepath'));
|
$definition = DBStructure::definition(self::$configCache->get('system', 'basepath'));
|
||||||
|
|
||||||
foreach ($definition AS $table => $structure) {
|
foreach ($definition AS $table => $structure) {
|
||||||
foreach ($structure['fields'] AS $field => $field_struct) {
|
foreach ($structure['fields'] AS $field => $field_struct) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ConfigFactory
|
||||||
*
|
*
|
||||||
* @return Config\IConfigAdapter
|
* @return Config\IConfigAdapter
|
||||||
*/
|
*/
|
||||||
public static function createConfig($type, $config)
|
public static function createConfig($type, Config\IConfigCache $config)
|
||||||
{
|
{
|
||||||
if ($type == 'preload') {
|
if ($type == 'preload') {
|
||||||
return new Config\PreloadConfigAdapter($config);
|
return new Config\PreloadConfigAdapter($config);
|
||||||
|
@ -41,7 +41,7 @@ class ConfigFactory
|
||||||
*
|
*
|
||||||
* @return Config\IPConfigAdapter
|
* @return Config\IPConfigAdapter
|
||||||
*/
|
*/
|
||||||
public static function createPConfig($type, $config, $uid = null)
|
public static function createPConfig($type, Config\IPConfigCache $config, $uid = null)
|
||||||
{
|
{
|
||||||
if ($type == 'preload') {
|
if ($type == 'preload') {
|
||||||
return new Config\PreloadPConfigAdapter($config, $uid);
|
return new Config\PreloadPConfigAdapter($config, $uid);
|
||||||
|
|
Loading…
Reference in a new issue