diff options
45 files changed, 177 insertions, 183 deletions
diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 047f5210df..b708992fb0 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -92,7 +92,6 @@ if (isset($_GET['avatar'])) /* @var $config \phpbb\config\config */ $config = $phpbb_container->get('config'); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); // load extensions 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 { diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index 511f850679..5d2398528b 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -233,11 +233,11 @@ if (!$get_info) $user_id = (int) $src_db->sql_fetchfield('max_user_id'); $src_db->sql_freeresult($result); - set_config('increment_user_id', ($user_id + 1), true); + $config->set('increment_user_id', ($user_id + 1), false); } else { - set_config('increment_user_id', 0, true); + $config->set('increment_user_id', 0, false); } // Overwrite maximum avatar width/height diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php index 089c569280..f8a6954634 100644 --- a/phpBB/install/convertors/functions_phpbb20.php +++ b/phpBB/install/convertors/functions_phpbb20.php @@ -514,12 +514,12 @@ function phpbb_user_id($user_id) // If there is a user id 1, we need to increment user ids. :/ if ($id === 1) { - set_config('increment_user_id', ($max_id + 1), true); + $config->set('increment_user_id', ($max_id + 1), false); $config['increment_user_id'] = $max_id + 1; } else { - set_config('increment_user_id', 0, true); + $config->set('increment_user_id', 0, false); $config['increment_user_id'] = 0; } } @@ -1682,29 +1682,29 @@ function phpbb_import_attach_config() } $src_db->sql_freeresult($result); - set_config('allow_attachments', 1); + $config->set('allow_attachments', 1); // old attachment mod? Must be very old if this entry do not exist... if (!empty($attach_config['display_order'])) { - set_config('display_order', $attach_config['display_order']); - } - set_config('max_filesize', $attach_config['max_filesize']); - set_config('max_filesize_pm', $attach_config['max_filesize_pm']); - set_config('attachment_quota', $attach_config['attachment_quota']); - set_config('max_attachments', $attach_config['max_attachments']); - set_config('max_attachments_pm', $attach_config['max_attachments_pm']); - set_config('allow_pm_attach', $attach_config['allow_pm_attach']); - - set_config('img_display_inlined', $attach_config['img_display_inlined']); - set_config('img_max_width', $attach_config['img_max_width']); - set_config('img_max_height', $attach_config['img_max_height']); - set_config('img_link_width', $attach_config['img_link_width']); - set_config('img_link_height', $attach_config['img_link_height']); - set_config('img_create_thumbnail', $attach_config['img_create_thumbnail']); - set_config('img_max_thumb_width', 400); - set_config('img_min_thumb_filesize', $attach_config['img_min_thumb_filesize']); - set_config('img_imagick', $attach_config['img_imagick']); + $config->set('display_order', $attach_config['display_order']); + } + $config->set('max_filesize', $attach_config['max_filesize']); + $config->set('max_filesize_pm', $attach_config['max_filesize_pm']); + $config->set('attachment_quota', $attach_config['attachment_quota']); + $config->set('max_attachments', $attach_config['max_attachments']); + $config->set('max_attachments_pm', $attach_config['max_attachments_pm']); + $config->set('allow_pm_attach', $attach_config['allow_pm_attach']); + + $config->set('img_display_inlined', $attach_config['img_display_inlined']); + $config->set('img_max_width', $attach_config['img_max_width']); + $config->set('img_max_height', $attach_config['img_max_height']); + $config->set('img_link_width', $attach_config['img_link_width']); + $config->set('img_link_height', $attach_config['img_link_height']); + $config->set('img_create_thumbnail', $attach_config['img_create_thumbnail']); + $config->set('img_max_thumb_width', 400); + $config->set('img_min_thumb_filesize', $attach_config['img_min_thumb_filesize']); + $config->set('img_imagick', $attach_config['img_imagick']); } /** diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 2d9dc097b0..d41bb05180 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -115,7 +115,6 @@ request_var('', 0, false, false, $request); // "dependency injection" for a func // Grab global variables, re-cache if necessary /* @var $config \phpbb\config\config */ $config = $phpbb_container->get('config'); -set_config(null, null, null, $config); set_config_count(null, null, null, $config); if (!isset($config['version_update_from'])) diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index 55bbcb5e02..e636e772a7 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -150,7 +150,6 @@ class install_convert extends module // We need to fill the config to let internal functions correctly work $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); // Detect if there is already a conversion in progress at this point and offer to resume @@ -391,7 +390,6 @@ class install_convert extends module // We need to fill the config to let internal functions correctly work $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); $convertor_tag = request_var('tag', ''); @@ -534,24 +532,27 @@ class install_convert extends module if (!sizeof($error)) { // Save convertor Status - set_config('convert_progress', serialize(array( + $config->set('convert_progress', serialize(array( 'step' => '', 'table_prefix' => $src_table_prefix, 'tag' => $convertor_tag, - )), true); - set_config('convert_db_server', serialize(array( + )), false); + $config->set('convert_db_server', serialize(array( 'dbms' => $src_dbms, 'dbhost' => $src_dbhost, 'dbport' => $src_dbport, 'dbname' => $src_dbname, - )), true); - set_config('convert_db_user', serialize(array( + )), false); + $config->set('convert_db_user', serialize(array( 'dbuser' => $src_dbuser, 'dbpasswd' => $src_dbpasswd, - )), true); + )), false); // Save options - set_config('convert_options', serialize(array('forum_path' => './../' . $forum_path, 'refresh' => $refresh)), true); + $config->set('convert_options', serialize(array( + 'forum_path' => './../' . $forum_path, + 'refresh' => $refresh + )), false); $template->assign_block_vars('checks', array( 'TITLE' => $lang['VERIFY_OPTIONS'], @@ -635,7 +636,6 @@ class install_convert extends module // We need to fill the config to let internal functions correctly work $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); // Override a couple of config variables for the duration @@ -788,7 +788,7 @@ class install_convert extends module if (!class_exists($search_type)) { $search_type = '\phpbb\search\fulltext_native'; - set_config('search_type', $search_type); + $config->set('search_type', $search_type); } if (!class_exists($search_type)) @@ -1561,26 +1561,26 @@ class install_convert extends module */ function save_convert_progress($step) { - global $convert, $language; + global $config, $convert, $language; // Save convertor Status - set_config('convert_progress', serialize(array( + $config->set('convert_progress', serialize(array( 'step' => $step, 'table_prefix' => $convert->src_table_prefix, 'tag' => $convert->convertor_tag, - )), true); + )), false); - set_config('convert_db_server', serialize(array( + $config->set('convert_db_server', serialize(array( 'dbms' => $convert->src_dbms, 'dbhost' => $convert->src_dbhost, 'dbport' => $convert->src_dbport, 'dbname' => $convert->src_dbname, - )), true); + )), false); - set_config('convert_db_user', serialize(array( + $config->set('convert_db_user', serialize(array( 'dbuser' => $convert->src_dbuser, 'dbpasswd' => $convert->src_dbpasswd, - )), true); + )), false); return $this->p_master->module_url . "?mode={$this->mode}&sub=in_progress&tag={$convert->convertor_tag}$step&language=$language"; } @@ -1759,7 +1759,7 @@ class install_convert extends module if (!isset($config['board_startdate']) || ($row['board_startdate'] < $config['board_startdate'] && $row['board_startdate'] > 0)) { - set_config('board_startdate', $row['board_startdate']); + $config->set('board_startdate', $row['board_startdate']); $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_regdate = ' . $row['board_startdate'] . ' WHERE user_id = ' . ANONYMOUS); } diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 303d185e84..819f5bec9e 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1493,7 +1493,6 @@ class install_install extends module // We need to fill the config to let internal functions correctly work $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); $error = false; @@ -1910,7 +1909,6 @@ class install_install extends module // We need to fill the config to let internal functions correctly work $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); $sql = 'SELECT group_id @@ -1984,7 +1982,6 @@ class install_install extends module // We need to fill the config to let internal functions correctly work $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); $user->session_begin(); @@ -2032,12 +2029,12 @@ class install_install extends module */ function disable_avatars_if_unwritable() { - global $phpbb_root_path; + global $config, $phpbb_root_path; if (!phpbb_is_writable($phpbb_root_path . 'images/avatars/upload/')) { - set_config('allow_avatar', 0); - set_config('allow_avatar_upload', 0); + $config->set('allow_avatar', 0); + $config->set('allow_avatar_upload', 0); } } diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 8f233b7efe..d8b50c4aa3 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -115,7 +115,6 @@ class install_update extends module // We need to fill the config to let internal functions correctly work $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); // Force template recompile @@ -236,7 +235,7 @@ class install_update extends module // Fill DB version if (empty($config['dbms_version'])) { - set_config('dbms_version', $db->sql_server_info(true)); + $config->set('dbms_version', $db->sql_server_info(true)); } if ($this->test_update === false) diff --git a/phpBB/phpbb/cache/driver/eaccelerator.php b/phpBB/phpbb/cache/driver/eaccelerator.php index 1697758acc..740855144f 100644 --- a/phpBB/phpbb/cache/driver/eaccelerator.php +++ b/phpBB/phpbb/cache/driver/eaccelerator.php @@ -44,9 +44,11 @@ class eaccelerator extends \phpbb\cache\driver\memory */ function tidy() { + global $config; + eaccelerator_gc(); - set_config('cache_last_gc', time(), true); + $config->set('cache_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 114959c06c..9c63d0010c 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -95,7 +95,7 @@ class file extends \phpbb\cache\driver\base */ function tidy() { - global $phpEx; + global $config, $phpEx; $dir = @opendir($this->cache_dir); @@ -149,7 +149,7 @@ class file extends \phpbb\cache\driver\base } } - set_config('cache_last_gc', time(), true); + $config->set('cache_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/cache/driver/memory.php b/phpBB/phpbb/cache/driver/memory.php index 0cef9c3483..baae22d809 100644 --- a/phpBB/phpbb/cache/driver/memory.php +++ b/phpBB/phpbb/cache/driver/memory.php @@ -81,9 +81,10 @@ abstract class memory extends \phpbb\cache\driver\base */ function tidy() { - // cache has auto GC, no need to have any code here :) + global $config; - set_config('cache_last_gc', time(), true); + // cache has auto GC, no need to have any code here :) + $config->set('cache_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/cache/driver/null.php b/phpBB/phpbb/cache/driver/null.php index a45cf97862..298731ea54 100644 --- a/phpBB/phpbb/cache/driver/null.php +++ b/phpBB/phpbb/cache/driver/null.php @@ -52,8 +52,10 @@ class null extends \phpbb\cache\driver\base */ function tidy() { + global $config; + // This cache always has a tidy room. - set_config('cache_last_gc', time(), true); + $config->set('cache_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/captcha/plugins/gd.php b/phpBB/phpbb/captcha/plugins/gd.php index 129fc0c907..5fe94af9df 100644 --- a/phpBB/phpbb/captcha/plugins/gd.php +++ b/phpBB/phpbb/captcha/plugins/gd.php @@ -80,7 +80,7 @@ class gd extends captcha_abstract $value = request_var($captcha_var, 0); if ($value >= 0) { - set_config($captcha_var, $value); + $config->set($captcha_var, $value); } } diff --git a/phpBB/phpbb/captcha/plugins/recaptcha.php b/phpBB/phpbb/captcha/plugins/recaptcha.php index a335dedfce..369c84e7df 100644 --- a/phpBB/phpbb/captcha/plugins/recaptcha.php +++ b/phpBB/phpbb/captcha/plugins/recaptcha.php @@ -97,7 +97,7 @@ class recaptcha extends captcha_abstract $value = request_var($captcha_var, ''); if ($value) { - set_config($captcha_var, $value); + $config->set($captcha_var, $value); } } diff --git a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php index e8d3a3af64..918a565e06 100644 --- a/phpBB/phpbb/db/migration/data/v310/style_update_p1.php +++ b/phpBB/phpbb/db/migration/data/v310/style_update_p1.php @@ -62,6 +62,8 @@ class style_update_p1 extends \phpbb\db\migration\migration public function styles_update() { + global $config; + // Get list of valid 3.1 styles $available_styles = array('prosilver'); @@ -163,7 +165,7 @@ class style_update_p1 extends \phpbb\db\migration\migration $default_style = $this->db->sql_fetchfield($result); $this->db->sql_freeresult($result); - set_config('default_style', $default_style); + $config->set('default_style', $default_style); $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; $this->sql_query($sql); diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index 1a0aba096f..da9de56009 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -188,8 +188,8 @@ class fulltext_mysql extends \phpbb\search\base } $this->db->sql_freeresult($result); - set_config('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']); - set_config('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']); + $this->config->set('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']); + $this->config->set('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']); return false; } @@ -745,7 +745,7 @@ class fulltext_mysql extends \phpbb\search\base // destroy too old cached search results $this->destroy_cache(array()); - set_config('search_last_gc', time(), true); + $this->config->set('search_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index cb681ec270..b18015ba1a 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -1425,7 +1425,7 @@ class fulltext_native extends \phpbb\search\base // carry on ... it's okay ... I know when I'm not wanted boo hoo if (!$this->config['fulltext_native_load_upd']) { - set_config('search_last_gc', time(), true); + $this->config->set('search_last_gc', time(), false); return; } @@ -1460,7 +1460,7 @@ class fulltext_native extends \phpbb\search\base // by setting search_last_gc to the new time here we make sure that if a user reloads because the // following query takes too long, he won't run into it again - set_config('search_last_gc', time(), true); + $this->config->set('search_last_gc', time(), false); // Delete the matches $sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . ' @@ -1476,7 +1476,7 @@ class fulltext_native extends \phpbb\search\base $this->destroy_cache(array_unique($destroy_cache_words)); } - set_config('search_last_gc', time(), true); + $this->config->set('search_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index b6af371d13..5a68f0cbfb 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -746,7 +746,7 @@ class fulltext_postgres extends \phpbb\search\base // destroy too old cached search results $this->destroy_cache(array()); - set_config('search_last_gc', time(), true); + $this->config->set('search_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php index c62bacf470..0be646ff06 100644 --- a/phpBB/phpbb/search/fulltext_sphinx.php +++ b/phpBB/phpbb/search/fulltext_sphinx.php @@ -140,7 +140,7 @@ class fulltext_sphinx if(!$this->config['fulltext_sphinx_id']) { - set_config('fulltext_sphinx_id', unique_id()); + $this->config->set('fulltext_sphinx_id', unique_id()); } $this->id = $this->config['fulltext_sphinx_id']; $this->indexes = 'index_phpbb_' . $this->id . '_delta;index_phpbb_' . $this->id . '_main'; @@ -211,7 +211,7 @@ class fulltext_sphinx } // Move delta to main index each hour - set_config('search_gc', 3600); + $this->config->set('search_gc', 3600); return false; } @@ -757,7 +757,7 @@ class fulltext_sphinx */ public function tidy($create = false) { - set_config('search_last_gc', time(), true); + $this->config->set('search_last_gc', time(), false); } /** diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index 114912b2aa..6f68dbf203 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -345,8 +345,8 @@ class session } else { - set_config('limit_load', '0'); - set_config('limit_search_load', '0'); + $config->set('limit_load', '0'); + $config->set('limit_search_load', '0'); } } @@ -1036,7 +1036,7 @@ class session { // Less than 10 users, update gc timer ... else we want gc // called again to delete other sessions - set_config('session_last_gc', $this->time_now, true); + $config->set('session_last_gc', $this->time_now, false); if ($config['max_autologin_time']) { diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index f76e967484..8638648898 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -39,7 +39,6 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $db = $this->db = $this->new_dbal(); $config = $this->config = new \phpbb\config\config(array('cron_lock' => '0')); - set_config(null, null, null, $this->config); $this->lock = new \phpbb\lock\db('cron_lock', $this->config, $this->db); $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index d5c78c64ad..272fc751c6 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -32,7 +32,6 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case 'load_online_time' => 5, 'search_type' => '\phpbb\search\fulltext_mysql', )); - set_config(false, false, false, $config); set_config_count(false, false, false, $config); $cache = new phpbb_mock_null_cache(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php index 6fc813cb38..389eab4152 100644 --- a/tests/lock/db_test.php +++ b/tests/lock/db_test.php @@ -30,7 +30,6 @@ class phpbb_lock_db_test extends phpbb_database_test_case $db = $this->db = $this->new_dbal(); $config = $this->config = new \phpbb\config\config(array('rand_seed' => '', 'rand_seed_last_update' => '0')); - set_config(null, null, null, $this->config); $this->lock = new \phpbb\lock\db('test_lock', $this->config, $this->db); } diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 0d1bda95ce..0d532882c6 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -40,8 +40,6 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_content.' . $phpEx); - set_config(false, false, false, $this->config); - $this->container->set('groupposition.legend', new \phpbb\groupposition\legend( $this->db, $this->user diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 5e770f71c9..fd5f33466b 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -70,7 +70,6 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c // Config $config = new \phpbb\config\config(array('num_topics' => 1,'num_posts' => 1,)); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); $cache = new \phpbb\cache\service( diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index c43eff729c..2d24950275 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -33,7 +33,6 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $db = $this->new_dbal(); $config = new \phpbb\config\config(array()); - set_config(null, null, null, $config); set_config_count(null, null, null, $config); $cache = new \phpbb\cache\service( diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 505eb7006f..99e7d27bea 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -84,7 +84,6 @@ class phpbb_session_testable_factory request_var(null, null, null, null, $request); $config = $this->config = new \phpbb\config\config($this->get_config_data()); - set_config(null, null, null, $config); $db = $dbal; diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 8f6d85fe14..984c0dcdcf 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -577,7 +577,7 @@ class phpbb_functional_test_case extends phpbb_test_case { require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); } - set_config(null, null, null, $config); + set_config_count(null, null, null, $config); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $passwords_manager = $this->get_passwords_manager(); diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php index c56be1f81e..647fcef2af 100644 --- a/tests/tree/nestedset_forum_base.php +++ b/tests/tree/nestedset_forum_base.php @@ -59,7 +59,6 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case global $config; $config = $this->config = new \phpbb\config\config(array('nestedset_forum_lock' => 0)); - set_config(null, null, null, $this->config); $this->lock = new \phpbb\lock\db('nestedset_forum_lock', $this->config, $this->db); $this->set = new \phpbb\tree\nestedset_forum($this->db, $this->lock, 'phpbb_forums'); |