aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Darricau <github@nicofuma.fr>2017-04-19 23:01:35 +0200
committerTristan Darricau <github@nicofuma.fr>2017-04-19 23:01:35 +0200
commitc61e43cc91a537ee3251a095f5124ab534197098 (patch)
tree12bde64d51fe9cbe8badf79a32e2f2ae29634ac7
parent3661398a78a13867b97e01560ce968052db65329 (diff)
parenta8d28d6bc8ee3914f35262e975f54b521bb3730c (diff)
downloadforums-c61e43cc91a537ee3251a095f5124ab534197098.tar
forums-c61e43cc91a537ee3251a095f5124ab534197098.tar.gz
forums-c61e43cc91a537ee3251a095f5124ab534197098.tar.bz2
forums-c61e43cc91a537ee3251a095f5124ab534197098.tar.xz
forums-c61e43cc91a537ee3251a095f5124ab534197098.zip
Merge branch '3.1.x' into 3.2.x
* 3.1.x: [ticket/7336] Index first post when splitting topics [ticket/7336] Add tests for indexing first post after splitting topics
-rw-r--r--phpBB/includes/mcp/mcp_topic.php43
-rw-r--r--tests/functional/visibility_softdelete_test.php19
2 files changed, 54 insertions, 8 deletions
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php
index ba86484040..f02b23a70f 100644
--- a/phpBB/includes/mcp/mcp_topic.php
+++ b/phpBB/includes/mcp/mcp_topic.php
@@ -402,7 +402,7 @@ function mcp_topic_view($id, $mode, $action)
*/
function split_topic($action, $topic_id, $to_forum_id, $subject)
{
- global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config, $phpbb_log, $request;
+ global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config, $phpbb_log, $request, $phpbb_dispatcher;
$post_id_list = $request->variable('post_id_list', array(0));
$forum_id = $request->variable('forum_id', 0);
@@ -570,6 +570,47 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
WHERE post_id = {$post_id_list[0]}";
$db->sql_query($sql);
+ // Grab data for first post in split topic
+ $sql_array = array(
+ 'SELECT' => 'p.post_id, p.forum_id, p.poster_id, p.post_text, f.enable_indexing',
+ 'FROM' => array(
+ POSTS_TABLE => 'p',
+ ),
+ 'LEFT_JOIN' => array(
+ array(
+ 'FROM' => array(FORUMS_TABLE => 'f'),
+ 'ON' => 'p.forum_id = f.forum_id',
+ )
+ ),
+ 'WHERE' => "post_id = {$post_id_list[0]}",
+ );
+ $sql = $db->sql_build_query('SELECT', $sql_array);
+ $result = $db->sql_query($sql);
+ $first_post_data = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ // Index first post as if it were edited
+ if ($first_post_data['enable_indexing'])
+ {
+ // Select the search method and do some additional checks to ensure it can actually be utilised
+ $search_type = $config['search_type'];
+
+ if (!class_exists($search_type))
+ {
+ trigger_error('NO_SUCH_SEARCH_MODULE');
+ }
+
+ $error = false;
+ $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
+
+ if ($error)
+ {
+ trigger_error($error);
+ }
+
+ $search->index('edit', $first_post_data['post_id'], $first_post_data['post_text'], $subject, $first_post_data['poster_id'], $first_post_data['forum_id']);
+ }
+
// Copy topic subscriptions to new topic
$sql = 'SELECT user_id, notify_status
FROM ' . TOPICS_WATCH_TABLE . '
diff --git a/tests/functional/visibility_softdelete_test.php b/tests/functional/visibility_softdelete_test.php
index 39efc99a35..6450c00c1e 100644
--- a/tests/functional/visibility_softdelete_test.php
+++ b/tests/functional/visibility_softdelete_test.php
@@ -564,7 +564,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assertContainsLang('SPLIT_TOPIC_EXPLAIN', $crawler->text());
$form = $crawler->selectButton('Submit')->form(array(
- 'subject' => 'Soft Delete Topic #2',
+ 'subject' => 'Soft Delete Topic #2 with bang',
));
$form['to_forum_id']->select($this->data['forums']['Soft Delete #2']);
$form['post_id_list'][1]->tick();
@@ -597,6 +597,11 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'forum_topics_softdeleted' => 1,
'forum_last_post_id' => 0,
), 'after restoring #2');
+
+ // Assert new topic title is indexed as well
+ $this->add_lang('search');
+ self::request('GET', "search.php?keywords=bang&sid={$this->sid}");
+ $this->assertContains(sprintf($this->lang['FOUND_SEARCH_MATCHES'][1], 1), self::get_content());
}
public function test_move_topic_back()
@@ -609,7 +614,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
),
'topics' => array(
'Soft Delete Topic #1',
- 'Soft Delete Topic #2',
+ 'Soft Delete Topic #2 with bang',
),
'posts' => array(
'Soft Delete Topic #1',
@@ -618,7 +623,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
),
));
- $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #2'], 'MOVE_TOPIC');
+ $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #2 with bang'], 'MOVE_TOPIC');
$form = $crawler->selectButton('Yes')->form();
$form['to_forum_id']->select($this->data['forums']['Soft Delete #1']);
$crawler = self::submit($form);
@@ -644,7 +649,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
),
'topics' => array(
'Soft Delete Topic #1',
- 'Soft Delete Topic #2',
+ 'Soft Delete Topic #2 with bang',
),
'posts' => array(
'Soft Delete Topic #1',
@@ -664,7 +669,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
), 'before merging #1');
$this->add_lang('viewtopic');
- $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #2']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #2 with bang']}&sid={$this->sid}");
$bookmark_tag = $crawler->filter('a.bookmark-link');
$this->assertContainsLang('BOOKMARK_TOPIC', $bookmark_tag->text());
@@ -673,10 +678,10 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assertContainsLang('BOOKMARK_ADDED', $crawler_bookmark->text());
$this->add_lang('mcp');
- $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #2'], 'MERGE_TOPIC', $crawler);
+ $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #2 with bang'], 'MERGE_TOPIC', $crawler);
$this->assertContainsLang('SELECT_MERGE', $crawler->text());
- $crawler = self::request('GET', "mcp.php?f={$this->data['forums']['Soft Delete #1']}&t={$this->data['topics']['Soft Delete Topic #2']}&i=main&mode=forum_view&action=merge_topic&to_topic_id={$this->data['topics']['Soft Delete Topic #1']}");
+ $crawler = self::request('GET', "mcp.php?f={$this->data['forums']['Soft Delete #1']}&t={$this->data['topics']['Soft Delete Topic #2 with bang']}&i=main&mode=forum_view&action=merge_topic&to_topic_id={$this->data['topics']['Soft Delete Topic #1']}");
$this->assertContainsLang('MERGE_TOPICS_CONFIRM', $crawler->text());
$form = $crawler->selectButton('Yes')->form();