diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_attachments.php | 2 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_board.php | 10 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_captcha.php | 4 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_forums.php | 8 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_jabber.php | 14 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_main.php | 18 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_search.php | 8 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_send_statistics.php | 2 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_styles.php | 5 | ||||
-rw-r--r-- | phpBB/includes/compatibility_globals.php | 1 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 41 | ||||
-rw-r--r-- | phpBB/includes/functions_admin.php | 6 | ||||
-rw-r--r-- | phpBB/includes/functions_compatibility.php | 33 | ||||
-rw-r--r-- | phpBB/includes/functions_convert.php | 18 | ||||
-rw-r--r-- | phpBB/includes/functions_messenger.php | 4 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 24 | ||||
-rw-r--r-- | phpBB/includes/questionnaire/questionnaire.php | 2 |
17 files changed, 101 insertions, 99 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 223b4de2d6..e685d6e589 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -190,7 +190,7 @@ class acp_attachments if ($submit) { - set_config($config_name, $config_value); + $config->set($config_name, $config_value); } } diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 86566dc705..1950b7e1cb 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -532,7 +532,7 @@ class acp_board if ($submit) { - set_config($config_name, $config_value); + $config->set($config_name, $config_value); if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable'])) { @@ -568,7 +568,7 @@ class acp_board { if (!isset($config[$field])) { - set_config($field, ''); + $config->set($field, ''); } if (!isset($cfg_array[$field]) || strpos($field, 'legend') !== false) @@ -583,7 +583,7 @@ class acp_board if ($submit) { $updated_auth_settings = true; - set_config($field, $config_value); + $config->set($field, $config_value); } } } @@ -600,11 +600,11 @@ class acp_board { foreach ($old_auth_config as $config_name => $config_value) { - set_config($config_name, $config_value); + $config->set($config_name, $config_value); } trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING); } - set_config('auth_method', basename($cfg_array['auth_method'])); + $config->set('auth_method', basename($cfg_array['auth_method'])); } else { diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index c87fa51f88..ec55d8f6b6 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -71,7 +71,7 @@ class acp_captcha { foreach ($config_vars as $config_var => $options) { - set_config($config_var, request_var($config_var, $options['default'])); + $config->set($config_var, request_var($config_var, $options['default'])); } if ($selected !== $config['captcha_plugin']) @@ -82,7 +82,7 @@ class acp_captcha $old_captcha = $factory->get_instance($config['captcha_plugin']); $old_captcha->uninstall(); - set_config('captcha_plugin', $selected); + $config->set('captcha_plugin', $selected); $new_captcha = $factory->get_instance($config['captcha_plugin']); $new_captcha->install(); diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index fdf22da2be..df37c48ec3 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1962,7 +1962,7 @@ class acp_forums $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - set_config('num_posts', (int) $row['stat'], true); + $config->set('num_posts', (int) $row['stat'], false); $sql = 'SELECT COUNT(topic_id) AS stat FROM ' . TOPICS_TABLE . ' @@ -1971,7 +1971,7 @@ class acp_forums $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - set_config('num_topics', (int) $row['stat'], true); + $config->set('num_topics', (int) $row['stat'], false); $sql = 'SELECT COUNT(attach_id) as stat FROM ' . ATTACHMENTS_TABLE; @@ -1979,7 +1979,7 @@ class acp_forums $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - set_config('num_files', (int) $row['stat'], true); + $config->set('num_files', (int) $row['stat'], false); $sql = 'SELECT SUM(filesize) as stat FROM ' . ATTACHMENTS_TABLE; @@ -1987,7 +1987,7 @@ class acp_forums $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - set_config('upload_dir_size', (float) $row['stat'], true); + $config->set('upload_dir_size', (float) $row['stat'], false); return array(); } diff --git a/phpBB/includes/acp/acp_jabber.php b/phpBB/includes/acp/acp_jabber.php index 6033237b9d..d501e61cbf 100644 --- a/phpBB/includes/acp/acp_jabber.php +++ b/phpBB/includes/acp/acp_jabber.php @@ -103,13 +103,13 @@ class acp_jabber $db->sql_query($sql); } - set_config('jab_enable', $jab_enable); - set_config('jab_host', $jab_host); - set_config('jab_port', $jab_port); - set_config('jab_username', $jab_username); - set_config('jab_password', $jab_password); - set_config('jab_package_size', $jab_package_size); - set_config('jab_use_ssl', $jab_use_ssl); + $config->set('jab_enable', $jab_enable); + $config->set('jab_host', $jab_host); + $config->set('jab_port', $jab_port); + $config->set('jab_username', $jab_username); + $config->set('jab_password', $jab_password); + $config->set('jab_package_size', $jab_package_size); + $config->set('jab_use_ssl', $jab_use_ssl); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_' . $log); trigger_error($message . adm_back_link($this->u_action)); diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 3248f95819..56a8dc2d83 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -121,8 +121,8 @@ class acp_main trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } - set_config('record_online_users', 1, true); - set_config('record_online_date', time(), true); + $config->set('record_online_users', 1, false); + $config->set('record_online_date', time(), false); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESET_ONLINE'); if ($request->is_ajax()) @@ -141,35 +141,35 @@ class acp_main FROM ' . POSTS_TABLE . ' WHERE post_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); - set_config('num_posts', (int) $db->sql_fetchfield('stat'), true); + $config->set('num_posts', (int) $db->sql_fetchfield('stat'), false); $db->sql_freeresult($result); $sql = 'SELECT COUNT(topic_id) AS stat FROM ' . TOPICS_TABLE . ' WHERE topic_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); - set_config('num_topics', (int) $db->sql_fetchfield('stat'), true); + $config->set('num_topics', (int) $db->sql_fetchfield('stat'), false); $db->sql_freeresult($result); $sql = 'SELECT COUNT(user_id) AS stat FROM ' . USERS_TABLE . ' WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')'; $result = $db->sql_query($sql); - set_config('num_users', (int) $db->sql_fetchfield('stat'), true); + $config->set('num_users', (int) $db->sql_fetchfield('stat'), false); $db->sql_freeresult($result); $sql = 'SELECT COUNT(attach_id) as stat FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; $result = $db->sql_query($sql); - set_config('num_files', (int) $db->sql_fetchfield('stat'), true); + $config->set('num_files', (int) $db->sql_fetchfield('stat'), false); $db->sql_freeresult($result); $sql = 'SELECT SUM(filesize) as stat FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; $result = $db->sql_query($sql); - set_config('upload_dir_size', (float) $db->sql_fetchfield('stat'), true); + $config->set('upload_dir_size', (float) $db->sql_fetchfield('stat'), false); $db->sql_freeresult($result); if (!function_exists('update_last_username')) @@ -259,7 +259,7 @@ class acp_main trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } - set_config('board_startdate', time() - 1); + $config->set('board_startdate', time() - 1); $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESET_DATE'); if ($request->is_ajax()) @@ -664,7 +664,7 @@ class acp_main // Fill dbms version if not yet filled if (empty($config['dbms_version'])) { - set_config('dbms_version', $db->sql_server_info(true)); + $config->set('dbms_version', $db->sql_server_info(true)); } $this->tpl_name = 'acp_main'; diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 9ae6627650..0ca9e4d63d 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -133,7 +133,7 @@ class acp_search // only change config if anything was actually changed if ($submit && ($config[$config_name] != $config_value)) { - set_config($config_name, $config_value); + $config->set($config_name, $config_value); $updated = true; } } @@ -157,7 +157,7 @@ class acp_search { if (!method_exists($search, 'init') || !($error = $search->init())) { - set_config('search_type', $cfg_array['search_type']); + $config->set('search_type', $cfg_array['search_type']); if (!$updated) { @@ -578,6 +578,8 @@ class acp_search function save_state($state = false) { + global $config; + if ($state) { $this->state = $state; @@ -585,7 +587,7 @@ class acp_search ksort($this->state); - set_config('search_indexing_state', implode(',', $this->state), true); + $config->set('search_indexing_state', implode(',', $this->state), true); } /** diff --git a/phpBB/includes/acp/acp_send_statistics.php b/phpBB/includes/acp/acp_send_statistics.php index d178be2fb0..4c5786dbe9 100644 --- a/phpBB/includes/acp/acp_send_statistics.php +++ b/phpBB/includes/acp/acp_send_statistics.php @@ -38,7 +38,7 @@ class acp_send_statistics if (!isset($config['questionnaire_unique_id'])) { $install_id = unique_id(); - set_config('questionnaire_unique_id', $install_id); + $config->set('questionnaire_unique_id', $install_id); } else { diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index c297a46ec9..45f224f8b1 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -32,6 +32,9 @@ class acp_styles protected $styles_list_cols = 0; protected $reserved_style_names = array('adm', 'admin', 'all'); + /** @var \phpbb\config\config */ + protected $config; + /** @var \phpbb\db\driver\driver_interface */ protected $db; @@ -538,7 +541,7 @@ class acp_styles { trigger_error($this->user->lang['STYLE_DEFAULT_CHANGE_INACTIVE'] . adm_back_link($update_action), E_USER_WARNING); } - set_config('default_style', $id); + $this->config->set('default_style', $id); $this->cache->purge(); } diff --git a/phpBB/includes/compatibility_globals.php b/phpBB/includes/compatibility_globals.php index 8d91d60b62..0631c3c462 100644 --- a/phpBB/includes/compatibility_globals.php +++ b/phpBB/includes/compatibility_globals.php @@ -44,7 +44,6 @@ request_var('', 0, false, false, $request); // "dependency injection" for a func // Grab global variables, re-cache if necessary /* @var $config phpbb\config\db */ $config = $phpbb_container->get('config'); -set_config(null, null, null, $config); set_config_count(null, null, null, $config); /* @var $phpbb_log \phpbb\log\log_interface */ diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9a6206c8d1..0c1e69aa20 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -130,39 +130,6 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $ } /** -* Sets a configuration option's value. -* -* Please note that this function does not update the is_dynamic value for -* an already existing config option. -* -* @param string $config_name The configuration option's name -* @param string $config_value New configuration value -* @param bool $is_dynamic Whether this variable should be cached (false) or -* if it changes too frequently (true) to be -* efficiently cached. -* -* @return null -* -* @deprecated -*/ -function set_config($config_name, $config_value, $is_dynamic = false, \phpbb\config\config $set_config = null) -{ - static $config = null; - - if ($set_config !== null) - { - $config = $set_config; - - if (empty($config_name)) - { - return; - } - } - - $config->set($config_name, $config_value, !$is_dynamic); -} - -/** * Increments an integer config value directly in the database. * * @param string $config_name The configuration option's name @@ -235,8 +202,8 @@ function unique_id($extra = 'c') if ($dss_seeded !== true && ($config['rand_seed_last_update'] < time() - rand(1,10))) { - set_config('rand_seed_last_update', time(), true); - set_config('rand_seed', $config['rand_seed'], true); + $config->set('rand_seed_last_update', time(), false); + $config->set('rand_seed', $config['rand_seed'], false); $dss_seeded = true; } @@ -4783,8 +4750,8 @@ function page_header($page_title = '', $display_online_list = false, $item_id = if ($total_online_users > $config['record_online_users']) { - set_config('record_online_users', $total_online_users, true); - set_config('record_online_date', time(), true); + $config->set('record_online_users', $total_online_users, false); + $config->set('record_online_date', time(), false); } $l_online_record = $user->lang('RECORD_ONLINE_USERS', (int) $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5279571c6a..16693d1c0a 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3040,7 +3040,7 @@ function tidy_warnings() $db->sql_transaction('commit'); } - set_config('warnings_last_gc', time(), true); + $config->set('warnings_last_gc', time(), false); } /** @@ -3048,7 +3048,7 @@ function tidy_warnings() */ function tidy_database() { - global $db; + global $config, $db; // Here we check permission consistency @@ -3073,7 +3073,7 @@ function tidy_database() WHERE ' . $db->sql_in_set('forum_id', $forum_ids, true); $db->sql_query($sql); - set_config('database_last_gc', time(), true); + $config->set('database_last_gc', time(), false); } /** diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index 014f5d40e3..552eaaeb80 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -264,3 +264,36 @@ function add_log() return $phpbb_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data); } + +/** + * Sets a configuration option's value. + * + * Please note that this function does not update the is_dynamic value for + * an already existing config option. + * + * @param string $config_name The configuration option's name + * @param string $config_value New configuration value + * @param bool $is_dynamic Whether this variable should be cached (false) or + * if it changes too frequently (true) to be + * efficiently cached. + * + * @return null + * + * @deprecated 3.1.0 (To be removed: 3.3.0) + */ +function set_config($config_name, $config_value, $is_dynamic = false, \phpbb\config\config $set_config = null) +{ + static $config = null; + + if ($set_config !== null) + { + $config = $set_config; + + if (empty($config_name)) + { + return; + } + } + + $config->set($config_name, $config_value, !$is_dynamic); +} diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 61ab4721c4..ea7816077d 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -1312,7 +1312,7 @@ function restore_config($schema) $config_value = truncate_string(utf8_htmlspecialchars($config_value), 255, 255, false); } - set_config($config_name, $config_value); + $config->set($config_name, $config_value); } } } @@ -1968,9 +1968,9 @@ function update_dynamic_config() if ($row) { - set_config('newest_user_id', $row['user_id'], true); - set_config('newest_username', $row['username'], true); - set_config('newest_user_colour', $row['user_colour'], true); + $config->set('newest_user_id', $row['user_id'], false); + $config->set('newest_username', $row['username'], false); + $config->set('newest_user_colour', $row['user_colour'], false); } // Also do not reset record online user/date. There will be old data or the fresh data from the schema. @@ -1984,7 +1984,7 @@ function update_dynamic_config() $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - set_config('num_posts', (int) $row['stat'], true); + $config->set('num_posts', (int) $row['stat'], false); $sql = 'SELECT COUNT(topic_id) AS stat FROM ' . TOPICS_TABLE . ' @@ -1993,7 +1993,7 @@ function update_dynamic_config() $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - set_config('num_topics', (int) $row['stat'], true); + $config->set('num_topics', (int) $row['stat'], false); $sql = 'SELECT COUNT(user_id) AS stat FROM ' . USERS_TABLE . ' @@ -2002,20 +2002,20 @@ function update_dynamic_config() $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - set_config('num_users', (int) $row['stat'], true); + $config->set('num_users', (int) $row['stat'], false); $sql = 'SELECT COUNT(attach_id) as stat FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; $result = $db->sql_query($sql); - set_config('num_files', (int) $db->sql_fetchfield('stat'), true); + $config->set('num_files', (int) $db->sql_fetchfield('stat'), false); $db->sql_freeresult($result); $sql = 'SELECT SUM(filesize) as stat FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; $result = $db->sql_query($sql); - set_config('upload_dir_size', (float) $db->sql_fetchfield('stat'), true); + $config->set('upload_dir_size', (float) $db->sql_fetchfield('stat'), false); $db->sql_freeresult($result); /** diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 6ea80f2a66..199cda829d 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -717,14 +717,14 @@ class queue { if (!$have_cache_file) { - set_config('last_queue_run', time(), true); + $config->set('last_queue_run', time(), false); } $lock->release(); return; } - set_config('last_queue_run', time(), true); + $config->set('last_queue_run', time(), false); include($this->cache_file); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index c51ad7b281..a2cdd29a3d 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -89,7 +89,7 @@ function user_get_id_name(&$user_id_ary, &$username_ary, $user_type = false) */ function update_last_username() { - global $db; + global $config, $db; // Get latest username $sql = 'SELECT user_id, username, user_colour @@ -102,9 +102,9 @@ function update_last_username() if ($row) { - set_config('newest_user_id', $row['user_id'], true); - set_config('newest_username', $row['username'], true); - set_config('newest_user_colour', $row['user_colour'], true); + $config->set('newest_user_id', $row['user_id'], false); + $config->set('newest_username', $row['username'], false); + $config->set('newest_user_colour', $row['user_colour'], false); } } @@ -138,7 +138,7 @@ function user_update_name($old_name, $new_name) if ($config['newest_username'] == $old_name) { - set_config('newest_username', $new_name, true); + $config->set('newest_username', $new_name, false); } /** @@ -335,8 +335,8 @@ function user_add($user_row, $cp_data = false, $notifications_data = null) // set the newest user and adjust the user count if the user is a normal user and no activation mail is sent if ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_FOUNDER) { - set_config('newest_user_id', $user_id, true); - set_config('newest_username', $user_row['username'], true); + $config->set('newest_user_id', $user_id, false); + $config->set('newest_username', $user_row['username'], false); set_config_count('num_users', 1, true); $sql = 'SELECT group_colour @@ -346,7 +346,7 @@ function user_add($user_row, $cp_data = false, $notifications_data = null) $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - set_config('newest_user_colour', $row['group_colour'], true); + $config->set('newest_user_colour', $row['group_colour'], false); } // Use default notifications settings if notifications_data is not set @@ -3193,7 +3193,7 @@ function group_validate_groupname($group_id, $group_name) */ function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false) { - global $phpbb_container, $db, $phpbb_dispatcher; + global $config, $phpbb_container, $db, $phpbb_dispatcher; if (empty($user_id_ary)) { @@ -3263,8 +3263,8 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal if (isset($sql_ary[$avatar_option])) { $avatar_sql_ary[$avatar_option] = $sql_ary[$avatar_option]; - } } + } $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $avatar_sql_ary) . " @@ -3305,11 +3305,9 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal WHERE " . $db->sql_in_set('topic_last_poster_id', $user_id_ary); $db->sql_query($sql); - global $config; - if (in_array($config['newest_user_id'], $user_id_ary)) { - set_config('newest_user_colour', $sql_ary['user_colour'], true); + $config->set('newest_user_colour', $sql_ary['user_colour'], false); } } diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index 63ea432863..8fe93735ee 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -230,7 +230,7 @@ class phpbb_questionnaire_phpbb_data_provider if (empty($config['questionnaire_unique_id'])) { $this->unique_id = unique_id(); - set_config('questionnaire_unique_id', $this->unique_id); + $config->set('questionnaire_unique_id', $this->unique_id); } else { |