mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 12:03:21 +01:00
Fix race condition for updating post/topic/etc. counter. (reported by BartVB)
please do not try such fixes at home - the correct solution would be to create a second config table with integer columns. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9398 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
bcabff8a1f
commit
e461162847
@ -125,6 +125,7 @@
|
||||
<li>[Fix] Flash files do not display anymore after update to flash player 10 (Bug #41315)</li>
|
||||
<li>[Fix] Use FQDN for SMTP EHLO/HELO command. (Bug #41025)</li>
|
||||
<li>[Fix] Mass Email works again for users with empty jabber address but notification set to 'both'. (Bug #39755)</li>
|
||||
<li>[Fix] Fix race condition for updating post/topic/etc. counter. (reported by BartVB)</li>
|
||||
<li>[Change] Allow download of conflicting file for later reference in automatic updater</li>
|
||||
<li>[Change] Default difference view is now 'inline' instead of 'side by side'</li>
|
||||
<li>[Change] Added new option for merging differences to conflicting files in automatic updater</li>
|
||||
|
@ -1003,8 +1003,8 @@ class acp_attachments
|
||||
|
||||
if ($files_added)
|
||||
{
|
||||
set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true);
|
||||
set_config('num_files', $config['num_files'] + $files_added, true);
|
||||
set_config_count('upload_dir_size', $space_taken, true);
|
||||
set_config_count('num_files', $files_added, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,6 +164,37 @@ function set_config($config_name, $config_value, $is_dynamic = false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set dynamic config value with arithmetic operation.
|
||||
*/
|
||||
function set_config_count($config_name, $increment, $is_dynamic = false)
|
||||
{
|
||||
global $db, $cache;
|
||||
|
||||
switch ($db->sql_layer)
|
||||
{
|
||||
case 'firebird':
|
||||
$sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as CHAR)';
|
||||
break;
|
||||
|
||||
case 'postgres':
|
||||
$sql_update = 'int4(config_value) + ' . (int) $increment;
|
||||
break;
|
||||
|
||||
// MySQL, SQlite, mssql, mssql_odbc, oracle
|
||||
default:
|
||||
$sql_update = 'config_value + ' . (int) $increment;
|
||||
break;
|
||||
}
|
||||
|
||||
$db->sql_query('UPDATE ' . CONFIG_TABLE . ' SET config_value = ' . $sql_update . " WHERE config_name = '" . $db->sql_escape($config_name) . "'");
|
||||
|
||||
if (!$is_dynamic)
|
||||
{
|
||||
$cache->destroy('config');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an alphanumeric random string of given length
|
||||
*/
|
||||
|
@ -619,7 +619,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
|
||||
|
||||
if ($approved_topics)
|
||||
{
|
||||
set_config('num_topics', $config['num_topics'] - $approved_topics, true);
|
||||
set_config_count('num_topics', $approved_topics * (-1), true);
|
||||
}
|
||||
|
||||
return $return;
|
||||
@ -776,7 +776,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
|
||||
|
||||
if ($approved_posts)
|
||||
{
|
||||
set_config('num_posts', $config['num_posts'] - $approved_posts, true);
|
||||
set_config_count('num_posts', $approved_posts * (-1), true);
|
||||
}
|
||||
|
||||
// We actually remove topics now to not be inconsistent (the delete_topics function calls this function too)
|
||||
@ -903,8 +903,8 @@ function delete_attachments($mode, $ids, $resync = true)
|
||||
|
||||
if ($space_removed || $files_removed)
|
||||
{
|
||||
set_config('upload_dir_size', $config['upload_dir_size'] - $space_removed, true);
|
||||
set_config('num_files', $config['num_files'] - $files_removed, true);
|
||||
set_config_count('upload_dir_size', $space_removed * (-1), true);
|
||||
set_config_count('num_files', $files_removed * (-1), true);
|
||||
}
|
||||
|
||||
// If we do not resync, we do not need to adjust any message, post, topic or user entries
|
||||
|
@ -1849,8 +1849,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics = forum_topics - 1';
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies'] + 1);
|
||||
|
||||
set_config('num_topics', $config['num_topics'] - 1, true);
|
||||
set_config('num_posts', $config['num_posts'] - ($topic_row['topic_replies'] + 1), true);
|
||||
set_config_count('num_topics', -1, true);
|
||||
set_config_count('num_posts', ($topic_row['topic_replies'] + 1) * (-1), true);
|
||||
|
||||
// Only decrement this post, since this is the one non-approved now
|
||||
if ($auth->acl_get('f_postcount', $data['forum_id']))
|
||||
@ -1870,7 +1870,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1';
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - 1';
|
||||
|
||||
set_config('num_posts', $config['num_posts'] - 1, true);
|
||||
set_config_count('num_posts', -1, true);
|
||||
|
||||
if ($auth->acl_get('f_postcount', $data['forum_id']))
|
||||
{
|
||||
@ -2137,8 +2137,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
|
||||
if ($space_taken && $files_added)
|
||||
{
|
||||
set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true);
|
||||
set_config('num_files', $config['num_files'] + $files_added, true);
|
||||
set_config_count('upload_dir_size', $space_taken, true);
|
||||
set_config_count('num_files', $files_added, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2371,13 +2371,13 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
{
|
||||
if ($post_mode == 'post')
|
||||
{
|
||||
set_config('num_topics', $config['num_topics'] + 1, true);
|
||||
set_config('num_posts', $config['num_posts'] + 1, true);
|
||||
set_config_count('num_topics', 1, true);
|
||||
set_config_count('num_posts', 1, true);
|
||||
}
|
||||
|
||||
if ($post_mode == 'reply')
|
||||
{
|
||||
set_config('num_posts', $config['num_posts'] + 1, true);
|
||||
set_config_count('num_posts', 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1571,8 +1571,8 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||
|
||||
if ($space_taken && $files_added)
|
||||
{
|
||||
set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true);
|
||||
set_config('num_files', $config['num_files'] + $files_added, true);
|
||||
set_config_count('upload_dir_size', $space_taken, true);
|
||||
set_config_count('num_files', $files_added, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ function user_add($user_row, $cp_data = false)
|
||||
{
|
||||
set_config('newest_user_id', $user_id, true);
|
||||
set_config('newest_username', $user_row['username'], true);
|
||||
set_config('num_users', $config['num_users'] + 1, true);
|
||||
set_config_count('num_users', 1, true);
|
||||
|
||||
$sql = 'SELECT group_colour
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
@ -579,7 +579,7 @@ function user_delete($mode, $user_id, $post_username = false)
|
||||
// Decrement number of users if this user is active
|
||||
if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE)
|
||||
{
|
||||
set_config('num_users', $config['num_users'] - 1, true);
|
||||
set_config_count('num_users', -1, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -660,12 +660,12 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
|
||||
|
||||
if ($deactivated)
|
||||
{
|
||||
set_config('num_users', $config['num_users'] - $deactivated, true);
|
||||
set_config_count('num_users', $deactivated * (-1), true);
|
||||
}
|
||||
|
||||
if ($activated)
|
||||
{
|
||||
set_config('num_users', $config['num_users'] + $activated, true);
|
||||
set_config_count('num_users', $activated, true);
|
||||
}
|
||||
|
||||
// Update latest username
|
||||
|
@ -1194,8 +1194,8 @@ function mcp_fork_topic($topic_ids)
|
||||
}
|
||||
|
||||
sync('forum', 'forum_id', $to_forum_id);
|
||||
set_config('num_topics', $config['num_topics'] + sizeof($new_topic_id_list), true);
|
||||
set_config('num_posts', $config['num_posts'] + $total_posts, true);
|
||||
set_config_count('num_topics', sizeof($new_topic_id_list), true);
|
||||
set_config_count('num_posts', $total_posts, true);
|
||||
|
||||
foreach ($new_topic_id_list as $topic_id => $new_topic_id)
|
||||
{
|
||||
|
@ -663,12 +663,12 @@ function approve_post($post_id_list, $id, $mode)
|
||||
|
||||
if ($total_topics)
|
||||
{
|
||||
set_config('num_topics', $config['num_topics'] + $total_topics, true);
|
||||
set_config_count('num_topics', $total_topics, true);
|
||||
}
|
||||
|
||||
if ($total_posts)
|
||||
{
|
||||
set_config('num_posts', $config['num_posts'] + $total_posts, true);
|
||||
set_config_count('num_posts', $total_posts, true);
|
||||
}
|
||||
unset($topic_approve_sql, $topic_replies_sql, $post_approve_sql);
|
||||
|
||||
|
@ -501,7 +501,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
|
||||
$success_msg = 'TOPIC_SPLIT_SUCCESS';
|
||||
|
||||
// Update forum statistics
|
||||
set_config('num_topics', $config['num_topics'] + 1, true);
|
||||
set_config_count('num_topics', 1, true);
|
||||
|
||||
// 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>');
|
||||
|
Loading…
x
Reference in New Issue
Block a user