mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-07 01:06:48 +02:00
[task/config-class] Implemented a config class to replace the global array.
There is a phpbb_config class which simply holds an array and does not persist any data. It implements ArrayAccess, Countable and IteratorAggregate to allow regular use of configuration as if it was still an array. The phpbb_config_db class depends on an instance of the dbal and a cache driver. It obtains the configuration data from cache and database as necessary and persists data to the database. The functions set_config and set_config_count remain for backward compatability but they only call methods on the new config class now instead of directly manipulating the database and cache. PHPBB3-9988
This commit is contained in:
45
phpBB/includes/cache/service.php
vendored
45
phpBB/includes/cache/service.php
vendored
@@ -39,51 +39,6 @@ class phpbb_cache_service
|
||||
return call_user_func_array(array($this->acm, $method), $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get config values
|
||||
*/
|
||||
function obtain_config()
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (($config = $this->acm->get('config')) !== false)
|
||||
{
|
||||
$sql = 'SELECT config_name, config_value
|
||||
FROM ' . CONFIG_TABLE . '
|
||||
WHERE is_dynamic = 1';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$config[$row['config_name']] = $row['config_value'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$config = $cached_config = array();
|
||||
|
||||
$sql = 'SELECT config_name, config_value, is_dynamic
|
||||
FROM ' . CONFIG_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (!$row['is_dynamic'])
|
||||
{
|
||||
$cached_config[$row['config_name']] = $row['config_value'];
|
||||
}
|
||||
|
||||
$config[$row['config_name']] = $row['config_value'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->acm->put('config', $cached_config);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain list of naughty words and build preg style replacement arrays for use by the
|
||||
* calling script
|
||||
|
Reference in New Issue
Block a user