diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index b708992fb0..26a76d8438 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_count(null, null, null, $config);
 
 	// load extensions
 	/* @var $phpbb_extension_manager \phpbb\extension\manager */
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 0c1e69aa20..2ec61ecdd6 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -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
 *
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 9f94064a8f..10c0fc90c2 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -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);
 		}
 	}
 
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 a2cdd29a3d..74bead49c9 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
@@ -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
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index c084f5af52..92f91190dd 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -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)
 		{
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php
index d43594c564..0690ff89be 100644
--- a/phpBB/includes/mcp/mcp_topic.php
+++ b/phpBB/includes/mcp/mcp_topic.php
@@ -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>');
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index d41bb05180..bc8ea16338 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_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 e636e772a7..9f6116ed12 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_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;
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 819f5bec9e..b8f256f615 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_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);
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index d8b50c4aa3..cb00895a4b 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_count(null, null, null, $config);
 
 		// Force template recompile
 		$config['load_tplcompile'] = 1;
diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php
index 6ad6351a0c..dc966c37ae 100644
--- a/tests/content_visibility/delete_post_test.php
+++ b/tests/content_visibility/delete_post_test.php
@@ -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);
 
diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php
index 272fc751c6..0cb171c885 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_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();
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index fd5f33466b..2d621f82d3 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_count(null, null, null, $config);
 
 		$cache = new \phpbb\cache\service(
 			new \phpbb\cache\driver\null(),
diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php
index 2d24950275..5886c49512 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_count(null, null, null, $config);
 
 		$cache = new \phpbb\cache\service(
 			new \phpbb\cache\driver\null(),
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 984c0dcdcf..93876479d5 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -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();