aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_posting.php
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2007-07-04 14:22:15 +0000
committerDavid M <davidmj@users.sourceforge.net>2007-07-04 14:22:15 +0000
commit677d4b54e08834c2959dc2ce0ad291ff44b9d8cb (patch)
treef3fe6a5108b58a9f6234572252d03e9e29852089 /phpBB/includes/functions_posting.php
parentddf7bf137692c7563dbe84be2cd0eff851598213 (diff)
downloadforums-677d4b54e08834c2959dc2ce0ad291ff44b9d8cb.tar
forums-677d4b54e08834c2959dc2ce0ad291ff44b9d8cb.tar.gz
forums-677d4b54e08834c2959dc2ce0ad291ff44b9d8cb.tar.bz2
forums-677d4b54e08834c2959dc2ce0ad291ff44b9d8cb.tar.xz
forums-677d4b54e08834c2959dc2ce0ad291ff44b9d8cb.zip
#12981
git-svn-id: file:///svn/phpbb/trunk@7832 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_posting.php')
-rw-r--r--phpBB/includes/functions_posting.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 0f15f5b604..21b2677483 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -1315,6 +1315,29 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
$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))
{
// 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)
{
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);
if ($data['topic_type'] != POST_GLOBAL)