1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-24 20:17:58 +02:00

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
This commit is contained in:
Meik Sievertsen
2009-04-28 09:35:36 +00:00
parent 7c418dee55
commit 0f085848a6
2 changed files with 54 additions and 21 deletions

View File

@ -150,6 +150,7 @@
<li>[Fix] memberlist.php display formating can be distorted by posting long URL for website (Bug #36675 - Patch by TerraFrost)</li>
<li>[Fix] Display the online status of hidden users to users with the u_viewonline permission when viewing PMs.</li>
<li>[Fix] "Select all" selects much too much in Opera (Bug #42885 - Patch by TerraFrost and ToonArmy)</li>
<li>[Fix] Correct calculation of source/target forum statistics if mass moving topics with global announcements (Bug #44545)</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>
<li>[Change] Add link to user profile in the MCP for user notes and warn user.</li>

View File

@ -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 ($topics_authed_moved)
if ($topic_posts_removed)
{
$sync_sql[$forum_id][] = 'forum_topics = forum_topics - ' . (int) $topics_authed_moved;
$sync_sql[$forum_id][] = 'forum_posts = forum_posts - ' . $topic_posts_removed;
}
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_removed;
}
$success_msg = (sizeof($topic_ids) == 1) ? 'TOPIC_MOVED_SUCCESS' : 'TOPICS_MOVED_SUCCESS';