diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2009-04-28 09:35:36 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2009-04-28 09:35:36 +0000 |
commit | 0f085848a661b5ffe5eff8bc842abfe625752bb3 (patch) | |
tree | 0b4a2faebac31cc64603c418d1c97224122d82c1 /phpBB/includes/mcp | |
parent | 7c418dee552c9d6e59a209e807a61aa26723fea9 (diff) | |
download | forums-0f085848a661b5ffe5eff8bc842abfe625752bb3.tar forums-0f085848a661b5ffe5eff8bc842abfe625752bb3.tar.gz forums-0f085848a661b5ffe5eff8bc842abfe625752bb3.tar.bz2 forums-0f085848a661b5ffe5eff8bc842abfe625752bb3.tar.xz forums-0f085848a661b5ffe5eff8bc842abfe625752bb3.zip |
Correct calculation of source/target forum statistics if mass moving topics with global announcements (Bug #44545)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9491 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/mcp')
-rw-r--r-- | phpBB/includes/mcp/mcp_main.php | 72 |
1 files changed, 52 insertions, 20 deletions
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 0e0bfe7bf5..0dfe3b0086 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -594,44 +594,67 @@ function mcp_move_topic($topic_ids) $topic_data = get_topic_data($topic_ids); $leave_shadow = (isset($_POST['move_leave_shadow'])) ? true : false; - $topics_moved = sizeof($topic_ids); - $topics_authed_moved = 0; $forum_sync_data = array(); $forum_sync_data[$forum_id] = current($topic_data); $forum_sync_data[$to_forum_id] = $forum_data; + // Real topics added to target forum + $topics_moved = sizeof($topic_data); + + // Approved topics added to target forum + $topics_authed_moved = 0; + + // Posts (topic replies + topic post if approved) added to target forum + $topic_posts_added = 0; + + // Posts (topic replies + topic post if approved and not global announcement) removed from source forum + $topic_posts_removed = 0; + + // Real topics removed from source forum (all topics without global announcements) + $topics_removed = 0; + + // Approved topics removed from source forum (except global announcements) + $topics_authed_removed = 0; + foreach ($topic_data as $topic_id => $topic_info) { - if ($topic_info['topic_approved'] == '1') + if ($topic_info['topic_approved']) { $topics_authed_moved++; + $topic_posts_added++; + } + + $topic_posts_added += $topic_info['topic_replies']; + + if ($topic_info['topic_type'] != POST_GLOBAL) + { + $topics_removed++; + $topic_posts_removed += $topic_info['topic_replies']; + + if ($topic_info['topic_approved']) + { + $topics_authed_removed++; + $topic_posts_removed++; + } } } $db->sql_transaction('begin'); - $sql = 'SELECT SUM(t.topic_replies + t.topic_approved) as topic_posts - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.topic_id', $topic_ids); - $result = $db->sql_query($sql); - $row_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - $sync_sql = array(); - if ($row_data['topic_posts']) + if ($topic_posts_added) { - $sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . (int) $row_data['topic_posts']; - $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . (int) $row_data['topic_posts']; + $sync_sql[$to_forum_id][] = 'forum_posts = forum_posts + ' . $topic_posts_added; } if ($topics_authed_moved) { - $sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $topics_authed_moved; + $sync_sql[$to_forum_id][] = 'forum_topics = forum_topics + ' . (int) $topics_authed_moved; } - $sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) $topics_moved; + $sync_sql[$to_forum_id][] = 'forum_topics_real = forum_topics_real + ' . (int) $topics_moved; // Move topics, but do not resync yet move_topics($topic_ids, $to_forum_id, false); @@ -692,17 +715,26 @@ function mcp_move_topic($topic_ids) $db->sql_query('INSERT INTO ' . TOPICS_TABLE . $db->sql_build_array('INSERT', $shadow)); - $topics_authed_moved--; - $topics_moved--; + // Shadow topics only count on new "topics" and not posts... a shadow topic alone has 0 posts + $topics_removed--; + $topics_authed_removed--; } } unset($topic_data); - $sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) $topics_moved; + if ($topic_posts_removed) + { + $sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . $topic_posts_removed; + } - if ($topics_authed_moved) + if ($topics_removed) + { + $sync_sql[$forum_id][] = 'forum_topics_real = forum_topics_real - ' . (int) $topics_removed; + } + + if ($topics_authed_removed) { - $sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $topics_authed_moved; + $sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $topics_authed_removed; } $success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS'; |