diff options
author | Andreas Fischer <bantu@phpbb.com> | 2015-02-03 18:13:20 +0100 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2015-02-03 18:13:20 +0100 |
commit | 284aa8c496d658c196a0dfa3c90657415ee4c2ee (patch) | |
tree | 6ea6f60315c6ac672b194ea0e22288d77d7f9815 /phpBB/includes | |
parent | 3fb6d5b838c33dc31563de7febbe827647f85abc (diff) | |
parent | a633f3484c63fe4bd70df548b3ae4bd569bdef46 (diff) | |
download | forums-284aa8c496d658c196a0dfa3c90657415ee4c2ee.tar forums-284aa8c496d658c196a0dfa3c90657415ee4c2ee.tar.gz forums-284aa8c496d658c196a0dfa3c90657415ee4c2ee.tar.bz2 forums-284aa8c496d658c196a0dfa3c90657415ee4c2ee.tar.xz forums-284aa8c496d658c196a0dfa3c90657415ee4c2ee.zip |
Merge pull request #3281 from MGaetan89/ticket/13496
[ticket/13496] Change set_config_count() calls with $config->increment()
* MGaetan89/ticket/13496:
[ticket/13496] Update calls to `set_config_count()`
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_attachments.php | 4 | ||||
-rw-r--r-- | phpBB/includes/compatibility_globals.php | 1 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 30 | ||||
-rw-r--r-- | phpBB/includes/functions_admin.php | 8 | ||||
-rw-r--r-- | phpBB/includes/functions_compatibility.php | 27 | ||||
-rw-r--r-- | phpBB/includes/functions_posting.php | 8 | ||||
-rw-r--r-- | phpBB/includes/functions_privmsgs.php | 4 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 8 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 4 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_topic.php | 2 |
10 files changed, 46 insertions, 50 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index e685d6e589..c3c152c32f 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -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); } } } diff --git a/phpBB/includes/compatibility_globals.php b/phpBB/includes/compatibility_globals.php index 0631c3c462..996949809c 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_count(null, null, null, $config); /* @var $phpbb_log \phpbb\log\log_interface */ $phpbb_log = $phpbb_container->get('log'); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ce26334282..9535d2a735 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -130,36 +130,6 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $ } /** -* 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 * * @return string diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 16693d1c0a..1c9440934b 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -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 diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index 552eaaeb80..2673f74a62 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -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); +} diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index b15406533a..38d4df703f 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1937,9 +1937,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) . "'"; @@ -2112,8 +2112,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); } } diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 2bc5ef5afc..1c63338247 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -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); } } diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 4cc171f2d2..e4f237b686 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -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 @@ -803,12 +803,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 diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 8403c3588e..8bf6bf8c0c 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1516,8 +1516,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) { diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 35b4e35a8c..2d4131626f 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -603,7 +603,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'] . '&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 . '&t=' . $to_topic_id) . '">', '</a>'); |