git-svn-id: file:///svn/phpbb/trunk@7832 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
David M 2007-07-04 14:22:15 +00:00
parent ddf7bf1376
commit 677d4b54e0
2 changed files with 33 additions and 0 deletions

View file

@ -219,6 +219,7 @@ p a {
<li>[Fix] Consider viewonline permission when viewing friends/foes (Bug #12955)</li> <li>[Fix] Consider viewonline permission when viewing friends/foes (Bug #12955)</li>
<li>[Fix] Added proper unicode support to ban reasons (Bug #12947)</li> <li>[Fix] Added proper unicode support to ban reasons (Bug #12947)</li>
<li>[Fix] The forum/topic sync code now recognizes other ways that the latest post in a topic can be expressed (Bug #12947) - patch provided by APTX</li> <li>[Fix] The forum/topic sync code now recognizes other ways that the latest post in a topic can be expressed (Bug #12947) - patch provided by APTX</li>
<li>[Fix] Topic deletion via the user post deletion mechanism did not take into account statistics for forums that hold shadow topics (Bug #12981)</li>
</ul> </ul>

View file

@ -1315,6 +1315,29 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$db->sql_transaction('begin'); $db->sql_transaction('begin');
// we must make sure to update forums that contain the shadow'd topic
if ($post_mode == 'delete_topic')
{
$shadow_forum_ids = array();
$sql = 'SELECT forum_id
FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_moved_id', $topic_id);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if (!isset($shadow_forum_ids[(int) $row['forum_id']]))
{
$shadow_forum_ids[(int) $row['forum_id']] = 1;
}
else
{
$shadow_forum_ids[(int) $row['forum_id']]++;
}
}
$db->sql_freeresult($result);
}
if (!delete_posts('post_id', array($post_id), false, false)) if (!delete_posts('post_id', array($post_id), false, false))
{ {
// Try to delete topic, we may had an previous error causing inconsistency // Try to delete topic, we may had an previous error causing inconsistency
@ -1332,6 +1355,15 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
switch ($post_mode) switch ($post_mode)
{ {
case 'delete_topic': case 'delete_topic':
foreach ($shadow_forum_ids as $updated_forum => $topic_count)
{
// counting is fun! we only have to do sizeof($forum_ids) number of queries,
// even if the topic is moved back to where its shadow lives (we count how many times it is in a forum)
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_topics_real = forum_topics_real - ' . $topic_count . ', forum_topics = forum_topics - ' . $topic_count . ' WHERE forum_id = ' . $updated_forum);
update_post_information('forum', $updated_forum);
}
delete_topics('topic_id', array($topic_id), false); delete_topics('topic_id', array($topic_id), false);
if ($data['topic_type'] != POST_GLOBAL) if ($data['topic_type'] != POST_GLOBAL)