mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-16 06:58:55 +00:00
Compare commits
13 commits
2043d7fa5d
...
bf71cac4ef
Author | SHA1 | Date | |
---|---|---|---|
|
bf71cac4ef | ||
|
bc1e1732cf | ||
|
ee889ac98b | ||
|
b7d2243f6c | ||
|
59e8875fa8 | ||
|
f11512b580 | ||
|
1ae9a49811 | ||
|
5ef1a40083 | ||
|
d95437682e | ||
|
99ffd9205f | ||
|
80a08d9c54 | ||
|
f24373ea19 | ||
|
8d0d6c012c |
9 changed files with 395 additions and 264 deletions
2
.github/setup-sphinx.sh
vendored
2
.github/setup-sphinx.sh
vendored
|
@ -135,7 +135,7 @@ searchd
|
|||
read_timeout = 5
|
||||
max_children = 30
|
||||
pid_file = $SPHINX_DATA_DIR/searchd.pid
|
||||
binlog_path = $SPHINX_DATA_DIR/
|
||||
binlog_path = $SPHINX_DATA_DIR
|
||||
}
|
||||
" > $SPHINX_CONF
|
||||
|
||||
|
|
BIN
composer.phar
BIN
composer.phar
Binary file not shown.
579
phpBB/composer.lock
generated
579
phpBB/composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -112,10 +112,16 @@ abstract class base implements search_backend_interface
|
|||
}
|
||||
}
|
||||
|
||||
// If the sort direction differs from the direction in the cache, then reverse the ids array
|
||||
// If the sort direction differs from the direction in the cache, then recalculate array keys
|
||||
if ($reverse_ids)
|
||||
{
|
||||
$stored_ids = array_reverse($stored_ids);
|
||||
$keys = array_keys($stored_ids);
|
||||
array_walk($keys, function (&$value, $key) use ($result_count)
|
||||
{
|
||||
$value = ($value >= 0) ? $result_count - $value - 1 : $value;
|
||||
}
|
||||
);
|
||||
$stored_ids = array_combine($keys, $stored_ids);
|
||||
}
|
||||
|
||||
for ($i = $start, $n = $start + $per_page; ($i < $n) && ($i < $result_count); $i++)
|
||||
|
@ -166,6 +172,8 @@ abstract class base implements search_backend_interface
|
|||
}
|
||||
|
||||
$store_ids = array_slice($id_ary, 0, $length);
|
||||
$id_range = range($start, $start + $length - 1);
|
||||
$store_ids = array_combine($id_range, $store_ids);
|
||||
|
||||
// create a new resultset if there is none for this search_key yet
|
||||
// or add the ids to the existing resultset
|
||||
|
@ -200,29 +208,26 @@ abstract class base implements search_backend_interface
|
|||
$this->db->sql_query($sql);
|
||||
|
||||
$store = array(-1 => $result_count, -2 => $sort_dir);
|
||||
$id_range = range($start, $start + $length - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we use one set of results for both sort directions so we have to calculate the indizes
|
||||
// for the reversed array and we also have to reverse the ids themselves
|
||||
// for the reversed array
|
||||
if ($store[-2] != $sort_dir)
|
||||
{
|
||||
$store_ids = array_reverse($store_ids);
|
||||
$id_range = range($store[-1] - $start - $length, $store[-1] - $start - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$id_range = range($start, $start + $length - 1);
|
||||
$keys = array_keys($store_ids);
|
||||
array_walk($keys, function (&$value, $key) use ($store) {
|
||||
$value = $store[-1] - $value - 1;
|
||||
});
|
||||
$store_ids = array_combine($keys, $store_ids);
|
||||
}
|
||||
}
|
||||
|
||||
$store_ids = array_combine($id_range, $store_ids);
|
||||
|
||||
// append the ids
|
||||
if (is_array($store_ids))
|
||||
{
|
||||
$store += $store_ids;
|
||||
ksort($store);
|
||||
|
||||
// if the cache is too big
|
||||
if (count($store) - 2 > 20 * $this->config['search_block_size'])
|
||||
|
|
|
@ -952,7 +952,7 @@ class fulltext_sphinx implements search_backend_interface
|
|||
array('read_timeout', '5'),
|
||||
array('max_children', '30'),
|
||||
array('pid_file', $this->config['fulltext_sphinx_data_path'] . 'searchd.pid'),
|
||||
array('binlog_path', $this->config['fulltext_sphinx_data_path']),
|
||||
array('binlog_path', rtrim($this->config['fulltext_sphinx_data_path'], '/\\')), // Trim trailing slash
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -263,7 +263,12 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
|
|||
|
||||
// Ensure search index has been actually created
|
||||
$crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid);
|
||||
$posts_indexed = (int) $crawler->filter('#acp_search_index_' . str_replace('\\', '-', $search_type) . ' td')->eq(1)->text();
|
||||
$posts_indexed = (int) $crawler->filter('#acp_search_index_' . str_replace('\\', '-', $search_type) . ' td')->reduce(
|
||||
function ($node, $i) {
|
||||
// Find the value of total posts indexed
|
||||
return (strpos($node->text(), $this->lang('FULLTEXT_MYSQL_TOTAL_POSTS')) !== false || strpos($node->text(), $this->lang('TOTAL_WORDS')) !== false);
|
||||
})
|
||||
->nextAll()->eq(0)->text();
|
||||
$this->assertTrue($posts_indexed > 0);
|
||||
}
|
||||
|
||||
|
@ -300,7 +305,12 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
|
|||
|
||||
// Ensure search index has been actually removed
|
||||
$crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid);
|
||||
$posts_indexed = (int) $crawler->filter('#acp_search_index_' . str_replace('\\', '-', $this->search_backend) . ' td')->eq(1)->text();
|
||||
$posts_indexed = (int) $crawler->filter('#acp_search_index_' . str_replace('\\', '-', $this->search_backend) . ' td')->reduce(
|
||||
function ($node, $i) {
|
||||
// Find the value of total posts indexed
|
||||
return (strpos($node->text(), $this->lang('FULLTEXT_MYSQL_TOTAL_POSTS')) !== false || strpos($node->text(), $this->lang('TOTAL_WORDS')) !== false);
|
||||
})
|
||||
->nextAll()->eq(0)->text();
|
||||
$this->assertEquals(0, $posts_indexed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,10 @@ class phpbb_functional_search_sphinx_test extends phpbb_functional_search_base
|
|||
|
||||
if (!$backend || $this->search_backend == $backend)
|
||||
{
|
||||
$output = $retval = null;
|
||||
|
||||
// After creating phpBB search index, build Sphinx index
|
||||
exec('sudo -S service sphinxsearch stop', $output, $retval); // Attemtp to stop sphinxsearch service in case it's running
|
||||
exec('sudo -S service sphinxsearch stop', $output, $retval); // Attempt to stop sphinxsearch service in case it's running
|
||||
exec('sudo -S indexer --all', $output, $retval); // Run sphinxsearch indexer
|
||||
exec('sudo -S service sphinxsearch start', $output, $retval); // Attempt to start sphinxsearch service again
|
||||
}
|
||||
|
|
|
@ -601,7 +601,16 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
|
|||
// Assert new topic title is indexed as well
|
||||
$this->add_lang('search');
|
||||
self::request('GET', "search.php?keywords=bang&sid={$this->sid}");
|
||||
$this->assertStringContainsString(sprintf($this->lang['FOUND_SEARCH_MATCHES'][1], 1), self::get_content());
|
||||
|
||||
// Sphinx search doesn't apply to unapproved or softdeleted posts
|
||||
if (strpos($this->get_search_type(), 'fulltext_sphinx'))
|
||||
{
|
||||
$this->assertStringContainsString(sprintf($this->lang['FOUND_SEARCH_MATCHES'][2], 0), self::get_content());
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->assertStringContainsString(sprintf($this->lang['FOUND_SEARCH_MATCHES'][1], 1), self::get_content());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_move_topic_back()
|
||||
|
|
|
@ -895,6 +895,24 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
return $group_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current board's search type
|
||||
*
|
||||
* @return string Current search type setting
|
||||
*/
|
||||
protected function get_search_type()
|
||||
{
|
||||
$db = $this->get_db();
|
||||
$sql = 'SELECT config_value as search_type
|
||||
FROM ' . CONFIG_TABLE . "
|
||||
WHERE config_name = '" . $db->sql_escape('search_type') . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$search_type = $db->sql_fetchfield('search_type');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
return $search_type;
|
||||
}
|
||||
|
||||
protected function remove_user_group($group_name, $usernames)
|
||||
{
|
||||
global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $user, $phpbb_root_path, $phpEx;
|
||||
|
|
Loading…
Add table
Reference in a new issue