1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-23 09:07:43 +02:00

[ticket/13496] Update calls to set_config_count()

PHPBB3-13496
This commit is contained in:
Gaëtan Muller 2015-01-11 18:01:52 +01:00
parent df77174a2b
commit a633f3484c
20 changed files with 52 additions and 67 deletions

@ -92,7 +92,6 @@ if (isset($_GET['avatar']))
/* @var $config \phpbb\config\config */
$config = $phpbb_container->get('config');
set_config_count(null, null, null, $config);
// load extensions
/* @var $phpbb_extension_manager \phpbb\extension\manager */

@ -1036,8 +1036,8 @@ class acp_attachments
if ($files_added)
{
set_config_count('upload_dir_size', $space_taken, true);
set_config_count('num_files', $files_added, true);
$config->increment('upload_dir_size', $space_taken, false);
$config->increment('num_files', $files_added, false);
}
}
}

@ -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_count(null, null, null, $config);
/* @var $phpbb_log \phpbb\log\log_interface */
$phpbb_log = $phpbb_container->get('log');

@ -129,36 +129,6 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $
return $tmp_request->variable($var_name, $default, $multibyte, ($cookie) ? \phpbb\request\request_interface::COOKIE : \phpbb\request\request_interface::REQUEST);
}
/**
* Increments an integer config value directly in the database.
*
* @param string $config_name The configuration option's name
* @param int $increment Amount to increment by
* @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_count($config_name, $increment, $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->increment($config_name, $increment, !$is_dynamic);
}
/**
* Generates an alphanumeric random string of given length
*

@ -712,7 +712,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
if ($approved_topics)
{
set_config_count('num_topics', $approved_topics * (-1), true);
$config->increment('num_topics', $approved_topics * (-1), false);
}
/* @var $phpbb_notifications \phpbb\notification\manager */
@ -971,7 +971,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
if ($approved_posts && $post_count_sync)
{
set_config_count('num_posts', $approved_posts * (-1), true);
$config->increment('num_posts', $approved_posts * (-1), false);
}
// We actually remove topics now to not be inconsistent (the delete_topics function calls this function too)
@ -1104,8 +1104,8 @@ function delete_attachments($mode, $ids, $resync = true)
if ($space_removed || $files_removed)
{
set_config_count('upload_dir_size', $space_removed * (-1), true);
set_config_count('num_files', $files_removed * (-1), true);
$config->increment('upload_dir_size', $space_removed * (-1), false);
$config->increment('num_files', $files_removed * (-1), false);
}
// If we do not resync, we do not need to adjust any message, post, topic or user entries

@ -297,3 +297,30 @@ function set_config($config_name, $config_value, $is_dynamic = false, \phpbb\con
$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
* @param int $increment Amount to increment by
* @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_count($config_name, $increment, $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->increment($config_name, $increment, !$is_dynamic);
}

@ -1909,9 +1909,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
{
if ($post_mode == 'post')
{
set_config_count('num_topics', 1, true);
$config->increment('num_topics', 1, false);
}
set_config_count('num_posts', 1, true);
$config->increment('num_posts', 1, false);
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data['post_id'];
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'";
@ -2084,8 +2084,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
if ($space_taken && $files_added)
{
set_config_count('upload_dir_size', $space_taken, true);
set_config_count('num_files', $files_added, true);
$config->increment('upload_dir_size', $space_taken, false);
$config->increment('num_files', $files_added, false);
}
}

@ -1905,8 +1905,8 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
if ($space_taken && $files_added)
{
set_config_count('upload_dir_size', $space_taken, true);
set_config_count('num_files', $files_added, true);
$config->increment('upload_dir_size', $space_taken, false);
$config->increment('num_files', $files_added, false);
}
}

@ -337,7 +337,7 @@ function user_add($user_row, $cp_data = false, $notifications_data = null)
{
$config->set('newest_user_id', $user_id, false);
$config->set('newest_username', $user_row['username'], false);
set_config_count('num_users', 1, true);
$config->increment('num_users', 1, false);
$sql = 'SELECT group_colour
FROM ' . GROUPS_TABLE . '
@ -573,7 +573,7 @@ function user_delete($mode, $user_ids, $retain_username = true)
if ($num_users_delta != 0)
{
set_config_count('num_users', $num_users_delta, true);
$config->increment('num_users', $num_users_delta, false);
}
// Now do the invariant tasks
@ -773,12 +773,12 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
if ($deactivated)
{
set_config_count('num_users', $deactivated * (-1), true);
$config->increment('num_users', $deactivated * (-1), false);
}
if ($activated)
{
set_config_count('num_users', $activated, true);
$config->increment('num_users', $activated, false);
}
// Update latest username

@ -1515,8 +1515,8 @@ function mcp_fork_topic($topic_ids)
sync('topic', 'topic_id', $new_topic_id_list);
sync('forum', 'forum_id', $to_forum_id);
set_config_count('num_topics', sizeof($new_topic_id_list), true);
set_config_count('num_posts', $total_posts, true);
$config->increment('num_topics', sizeof($new_topic_id_list), false);
$config->increment('num_posts', $total_posts, false);
foreach ($new_topic_id_list as $topic_id => $new_topic_id)
{

@ -573,7 +573,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
$success_msg = 'TOPIC_SPLIT_SUCCESS';
// Update forum statistics
set_config_count('num_topics', 1, true);
$config->increment('num_topics', 1, false);
// Link back to both topics
$return_link = sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&amp;t=' . $post_info['topic_id']) . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&amp;t=' . $to_topic_id) . '">', '</a>');

@ -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_count(null, null, null, $config);
if (!isset($config['version_update_from']))
{

@ -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_count(null, null, null, $config);
// Detect if there is already a conversion in progress at this point and offer to resume
// It's quite possible that the user will get disconnected during a large conversion so they need to be able to resume it
@ -390,7 +389,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_count(null, null, null, $config);
$convertor_tag = request_var('tag', '');
@ -636,7 +634,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_count(null, null, null, $config);
// Override a couple of config variables for the duration
$config['max_quote_depth'] = 0;

@ -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_count(null, null, null, $config);
$error = false;
$search = new \phpbb\search\fulltext_native($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
@ -1909,7 +1908,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_count(null, null, null, $config);
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "
@ -1982,7 +1980,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_count(null, null, null, $config);
$user->session_begin();
$auth->login($data['admin_name'], $data['admin_pass1'], false, true, true);

@ -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_count(null, null, null, $config);
// Force template recompile
$config['load_tplcompile'] = 1;

@ -292,12 +292,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
{
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
$config['search_type'] = 'phpbb_mock_search';
$config = new \phpbb\config\config(array(
'num_posts' => 3,
'num_topics' => 1,
'search_type' => 'phpbb_mock_search',
));
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$phpbb_config = new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1));
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
set_config_count(null, null, null, $phpbb_config);
// Create auth mock
$auth = $this->getMock('\phpbb\auth\auth');
@ -313,7 +315,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
$phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $phpbb_config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
$phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason);

@ -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_count(false, false, false, $config);
$cache = new phpbb_mock_null_cache();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container = new phpbb_mock_container_builder();

@ -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_count(null, null, null, $config);
$cache = new \phpbb\cache\service(
new \phpbb\cache\driver\null(),

@ -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_count(null, null, null, $config);
$cache = new \phpbb\cache\service(
new \phpbb\cache\driver\null(),

@ -578,7 +578,6 @@ class phpbb_functional_test_case extends phpbb_test_case
require_once(__DIR__ . '/../../phpBB/includes/functions_user.php');
}
set_config_count(null, null, null, $config);
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$passwords_manager = $this->get_passwords_manager();