mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 03:54:10 +01:00
Fix bug #47705 - Out of range value for column 'topic_replies_real'
Authorised by: Kellanved git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9946 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
2a276bf7de
commit
3036fbc66f
@ -168,6 +168,7 @@
|
||||
<li>[Fix] Allow changing forum from select box under certain circumstances. (Bug #37525)</li>
|
||||
<li>[Fix] Display required fields notice on registration above the custom profile fields. (Bug #39665)</li>
|
||||
<li>[Fix] Copy poll options properly when copying topic. (Bug #39065)</li>
|
||||
<li>[Fix] Fix error with disapproval of topics having several queued posts only. (Bug #47705 - Patch by rxu)</li>
|
||||
<li>[Fix] Preserve newlines in template files (one newline had been always dropped after a template variable due to PHP's handling of closing tags)</li>
|
||||
<li>[Fix] Be less strict with FTP daemons when getting directory filelists. (Bug #46295)</li>
|
||||
<li>[Fix] Fix set_custom_template for database-stored styles (Bug #40515 - Patch by nickvergessen)</li>
|
||||
|
@ -859,89 +859,63 @@ function disapprove_post($post_id_list, $id, $mode)
|
||||
|
||||
if (confirm_box(true))
|
||||
{
|
||||
$disapprove_log = $disapprove_log_topics = $disapprove_log_posts = array();
|
||||
$topic_replies_real = $post_disapprove_list = array();
|
||||
|
||||
// If Topic -> forum_topics_real -= 1
|
||||
// If Post -> topic_replies_real -= 1
|
||||
|
||||
$num_disapproved = 0;
|
||||
$forum_topics_real = $topic_id_list = $forum_id_list = $topic_replies_real_sql = $post_disapprove_sql = $disapprove_log = array();
|
||||
|
||||
// Build a list of posts to be unapproved and get the related topics real replies count
|
||||
foreach ($post_info as $post_id => $post_data)
|
||||
{
|
||||
$topic_id_list[$post_data['topic_id']] = 1;
|
||||
|
||||
if ($post_data['forum_id'])
|
||||
$post_disapprove_list[$post_id] = $post_data['topic_id'];
|
||||
if (!isset($topic_replies_real[$post_data['topic_id']]))
|
||||
{
|
||||
$forum_id_list[$post_data['forum_id']] = 1;
|
||||
$topic_replies_real[$post_data['topic_id']] = $post_data['topic_replies_real'];
|
||||
}
|
||||
}
|
||||
|
||||
// Topic or Post. ;)
|
||||
/**
|
||||
* @todo this probably is a different method than the one used by delete_posts, does this cause counter inconsistency?
|
||||
*/
|
||||
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id)
|
||||
// Now we build the log array
|
||||
foreach ($post_disapprove_list as $post_id => $topic_id)
|
||||
{
|
||||
// If the count of disapproved posts for the topic is greater
|
||||
// than topic's real replies count, the whole topic is disapproved/deleted
|
||||
if (sizeof(array_keys($post_disapprove_list, $topic_id)) > $topic_replies_real[$topic_id])
|
||||
{
|
||||
if ($post_data['forum_id'])
|
||||
// Don't write the log more than once for every topic
|
||||
if (!isset($disapprove_log_topics[$topic_id]))
|
||||
{
|
||||
if (!isset($forum_topics_real[$post_data['forum_id']]))
|
||||
{
|
||||
$forum_topics_real[$post_data['forum_id']] = 0;
|
||||
}
|
||||
$forum_topics_real[$post_data['forum_id']]++;
|
||||
$num_disapproved++;
|
||||
// Build disapproved topics log
|
||||
$disapprove_log_topics[$topic_id] = array(
|
||||
'type' => 'topic',
|
||||
'post_subject' => $post_info[$post_id]['topic_title'],
|
||||
'forum_id' => $post_info[$post_id]['forum_id'],
|
||||
'topic_id' => 0, // useless to log a topic id, as it will be deleted
|
||||
);
|
||||
}
|
||||
|
||||
$disapprove_log[] = array(
|
||||
'type' => 'topic',
|
||||
'post_subject' => $post_data['post_subject'],
|
||||
'forum_id' => $post_data['forum_id'],
|
||||
'topic_id' => 0, // useless to log a topic id, as it will be deleted
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($topic_replies_real_sql[$post_data['topic_id']]))
|
||||
{
|
||||
$topic_replies_real_sql[$post_data['topic_id']] = 0;
|
||||
}
|
||||
$topic_replies_real_sql[$post_data['topic_id']]++;
|
||||
|
||||
$disapprove_log[] = array(
|
||||
// Build disapproved posts log
|
||||
$disapprove_log_posts[] = array(
|
||||
'type' => 'post',
|
||||
'post_subject' => $post_data['post_subject'],
|
||||
'forum_id' => $post_data['forum_id'],
|
||||
'topic_id' => $post_data['topic_id'],
|
||||
);
|
||||
}
|
||||
'post_subject' => $post_info[$post_id]['post_subject'],
|
||||
'forum_id' => $post_info[$post_id]['forum_id'],
|
||||
'topic_id' => $post_info[$post_id]['topic_id'],
|
||||
);
|
||||
|
||||
$post_disapprove_sql[] = $post_id;
|
||||
}
|
||||
|
||||
unset($post_data);
|
||||
|
||||
if (sizeof($forum_topics_real))
|
||||
{
|
||||
foreach ($forum_topics_real as $forum_id => $topics_real)
|
||||
{
|
||||
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
||||
SET forum_topics_real = forum_topics_real - $topics_real
|
||||
WHERE forum_id = $forum_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof($topic_replies_real_sql))
|
||||
{
|
||||
foreach ($topic_replies_real_sql as $topic_id => $num_replies)
|
||||
{
|
||||
$sql = 'UPDATE ' . TOPICS_TABLE . "
|
||||
SET topic_replies_real = topic_replies_real - $num_replies
|
||||
WHERE topic_id = $topic_id";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
// Get disapproved posts/topics counts separately
|
||||
$num_disapproved_topics = sizeof($disapprove_log_topics);
|
||||
$num_disapproved_posts = sizeof($disapprove_log_posts);
|
||||
|
||||
if (sizeof($post_disapprove_sql))
|
||||
// Build the whole log
|
||||
$disapprove_log = array_merge($disapprove_log_topics, $disapprove_log_posts);
|
||||
|
||||
// Unset unneeded arrays
|
||||
unset($post_data, $disapprove_log_topics, $disapprove_log_posts);
|
||||
|
||||
// Let's do the job - delete disapproved posts
|
||||
if (sizeof($post_disapprove_list))
|
||||
{
|
||||
if (!function_exists('delete_posts'))
|
||||
{
|
||||
@ -949,22 +923,15 @@ function disapprove_post($post_id_list, $id, $mode)
|
||||
}
|
||||
|
||||
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
|
||||
delete_posts('post_id', $post_disapprove_sql);
|
||||
// Note: function delete_posts triggers related forums/topics sync,
|
||||
// so we don't need to call update_post_information later and to adjust real topic replies or forum topics count manually
|
||||
delete_posts('post_id', array_keys($post_disapprove_list));
|
||||
|
||||
foreach ($disapprove_log as $log_data)
|
||||
{
|
||||
add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason);
|
||||
}
|
||||
}
|
||||
unset($post_disapprove_sql, $topic_replies_real_sql);
|
||||
|
||||
update_post_information('topic', array_keys($topic_id_list));
|
||||
|
||||
if (sizeof($forum_id_list))
|
||||
{
|
||||
update_post_information('forum', array_keys($forum_id_list));
|
||||
}
|
||||
unset($topic_id_list, $forum_id_list);
|
||||
|
||||
$messenger = new messenger();
|
||||
|
||||
@ -1032,13 +999,13 @@ function disapprove_post($post_id_list, $id, $mode)
|
||||
|
||||
$messenger->save_queue();
|
||||
|
||||
if (sizeof($forum_topics_real))
|
||||
if ($num_disapproved_topics)
|
||||
{
|
||||
$success_msg = ($num_disapproved == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
|
||||
$success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
|
||||
}
|
||||
else
|
||||
{
|
||||
$success_msg = (sizeof($post_id_list) == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
|
||||
$success_msg = ($num_disapproved_posts == 1) ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user