aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-06-09 22:57:27 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-06-09 22:57:27 +0200
commit771cbb2b3a8d025dc1b9453227efdb726399d9d1 (patch)
treeabe1bcdb610a7ea0c0aa03a56b494f1a661ec3d4
parentb6232aa9b213fbf62f5ce351bc79220daf243cc6 (diff)
parent7c4bd8cc76e9a0511b54752e88f18c3ee4be2ec6 (diff)
downloadforums-771cbb2b3a8d025dc1b9453227efdb726399d9d1.tar
forums-771cbb2b3a8d025dc1b9453227efdb726399d9d1.tar.gz
forums-771cbb2b3a8d025dc1b9453227efdb726399d9d1.tar.bz2
forums-771cbb2b3a8d025dc1b9453227efdb726399d9d1.tar.xz
forums-771cbb2b3a8d025dc1b9453227efdb726399d9d1.zip
Merge pull request #2434 from Nicofuma/ticket/8610
[ticket/8610] Merging topics does not handle bookmarks correctly * Nicofuma/ticket/8610: [ticket/8610] Use css selector instead of xPath [ticket/8610] Add functional test when two topics are merged [ticket/8610] Throw an error when the dest topic isn't set [ticket/8610] Fix bookmarks when merging all the posts of a topic [ticket/8610] Merging topics does not handle bookmarks correctly
-rw-r--r--phpBB/includes/mcp/mcp_forum.php20
-rw-r--r--phpBB/includes/mcp/mcp_topic.php22
-rw-r--r--tests/functional/visibility_softdelete_test.php8
3 files changed, 43 insertions, 7 deletions
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php
index 8d2d70bd3b..e63888e70e 100644
--- a/phpBB/includes/mcp/mcp_forum.php
+++ b/phpBB/includes/mcp/mcp_forum.php
@@ -378,14 +378,22 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
return;
}
- $topic_data = get_topic_data(array($to_topic_id), 'm_merge');
+ $sync_topics = array_merge($topic_ids, array($to_topic_id));
- if (!sizeof($topic_data))
+ $topic_data = get_topic_data($sync_topics, 'm_merge');
+
+ if (!sizeof($topic_data) || empty($topic_data[$to_topic_id]))
{
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
return;
}
+ $sync_forums = array();
+ foreach ($topic_data as $data)
+ {
+ $sync_forums[$data['forum_id']] = $data['forum_id'];
+ }
+
$topic_data = $topic_data[$to_topic_id];
$post_id_list = request_var('post_id_list', array(0));
@@ -436,7 +444,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
{
$to_forum_id = $topic_data['forum_id'];
- move_posts($post_id_list, $to_topic_id);
+ move_posts($post_id_list, $to_topic_id, false);
add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);
// Message and return links
@@ -453,6 +461,12 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
// Update the bookmarks table.
phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $topic_ids, $to_topic_id);
+ // Re-sync the topics and forums because the auto-sync was deactivated in the call of move_posts()
+ sync('topic_reported', 'topic_id', $sync_topics);
+ sync('topic_attachment', 'topic_id', $sync_topics);
+ sync('topic', 'topic_id', $sync_topics, true);
+ sync('forum', 'forum_id', $sync_forums, true, true);
+
// Link to the new topic
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&amp;t=' . $to_topic_id) . '">', '</a>');
$redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&amp;t=$to_topic_id");
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php
index 51802f1e4d..f8ce8aae7b 100644
--- a/phpBB/includes/mcp/mcp_topic.php
+++ b/phpBB/includes/mcp/mcp_topic.php
@@ -592,14 +592,22 @@ function merge_posts($topic_id, $to_topic_id)
return;
}
- $topic_data = get_topic_data(array($to_topic_id), 'm_merge');
+ $sync_topics = array($topic_id, $to_topic_id);
- if (!sizeof($topic_data))
+ $topic_data = get_topic_data($sync_topics, 'm_merge');
+
+ if (!sizeof($topic_data) || empty($topic_data[$to_topic_id]))
{
$template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
return;
}
+ $sync_forums = array();
+ foreach ($topic_data as $data)
+ {
+ $sync_forums[$data['forum_id']] = $data['forum_id'];
+ }
+
$topic_data = $topic_data[$to_topic_id];
$post_id_list = request_var('post_id_list', array(0));
@@ -634,7 +642,7 @@ function merge_posts($topic_id, $to_topic_id)
{
$to_forum_id = $topic_data['forum_id'];
- move_posts($post_id_list, $to_topic_id);
+ move_posts($post_id_list, $to_topic_id, false);
add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);
// Message and return links
@@ -642,7 +650,7 @@ function merge_posts($topic_id, $to_topic_id)
// Does the original topic still exist? If yes, link back to it
$sql = 'SELECT forum_id
- FROM ' . TOPICS_TABLE . '
+ FROM ' . POSTS_TABLE . '
WHERE topic_id = ' . $topic_id;
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
@@ -666,6 +674,12 @@ function merge_posts($topic_id, $to_topic_id)
phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', array($topic_id), $to_topic_id);
}
+ // Re-sync the topics and forums because the auto-sync was deactivated in the call of move_posts()
+ sync('topic_reported', 'topic_id', $sync_topics);
+ sync('topic_attachment', 'topic_id', $sync_topics);
+ sync('topic', 'topic_id', $sync_topics, true);
+ sync('forum', 'forum_id', $sync_forums, true, true);
+
// Link to the new topic
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&amp;t=' . $to_topic_id) . '">', '</a>');
$redirect = request_var('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&amp;t=$to_topic_id");
diff --git a/tests/functional/visibility_softdelete_test.php b/tests/functional/visibility_softdelete_test.php
index bc722ea043..5b5f09905c 100644
--- a/tests/functional/visibility_softdelete_test.php
+++ b/tests/functional/visibility_softdelete_test.php
@@ -595,8 +595,15 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
), 'before merging #1');
+ $this->add_lang('viewtopic');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #2']}&sid={$this->sid}");
+ $bookmark_tag = $crawler->filter('a.bookmark-link');
+ $this->assertContainsLang('BOOKMARK_TOPIC', $bookmark_tag->text());
+ $bookmark_link = $bookmark_tag->attr('href');
+ $crawler_bookmark = self::request('GET', $bookmark_link);
+ $this->assertContainsLang('BOOKMARK_ADDED', $crawler_bookmark->text());
+
$this->add_lang('mcp');
$form = $crawler->selectButton('Go')->eq(1)->form();
$form['action']->select('merge_topic');
@@ -613,6 +620,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
$this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
$this->assertContainsLang('POST_DELETED_ACTION', $crawler->filter('body')->text());
+ $this->assertContainsLang('BOOKMARK_TOPIC_REMOVE', $crawler->filter('body')->text());
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 1,