diff --git a/phpBB/develop/search_fill.php b/phpBB/develop/search_fill.php deleted file mode 100644 index 1dcdcdace6..0000000000 --- a/phpBB/develop/search_fill.php +++ /dev/null @@ -1,121 +0,0 @@ -session_begin(); -$auth->acl($user->data); -$user->setup(); - -$search_type = $config['search_type']; - -if (!class_exists($search_type)) -{ - trigger_error('NO_SUCH_SEARCH_MODULE'); -} - -$search = new $search_type($auth, $config, $db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx); - -print "\n
\n"; - -// -// Fetch a batch of posts_text entries -// -$sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id - FROM ". POSTS_TABLE; -if ( !($result = $db->sql_query($sql)) ) -{ - $error = $db->sql_error(); - die("Couldn't get maximum post ID :: " . $sql . " :: " . $error['message']); -} - -$max_post_id = $db->sql_fetchrow($result); - -$totalposts = $max_post_id['total']; -$max_post_id = $max_post_id['max_post_id']; - -$postcounter = (!isset($HTTP_GET_VARS['batchstart'])) ? 0 : $HTTP_GET_VARS['batchstart']; - -$batchsize = 200; // Process this many posts per loop -$batchcount = 0; -for(;$postcounter <= $max_post_id; $postcounter += $batchsize) -{ - $batchstart = $postcounter + 1; - $batchend = $postcounter + $batchsize; - $batchcount++; - - $sql = "SELECT * - FROM " . POSTS_TABLE . " - WHERE post_id - BETWEEN $batchstart - AND $batchend"; - if( !($result = $db->sql_query($sql)) ) - { - $error = $db->sql_error(); - die("Couldn't get post_text :: " . $sql . " :: " . $error['message']); - } - - $rowset = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - $post_rows = count($rowset); - - if( $post_rows ) - { - - // $sql = "LOCK TABLES ".POST_TEXT_TABLE." WRITE"; - // $result = $db->sql_query($sql); - print "\n\nRestart from posting $batchstart
\n";
-
- // For every post in the batch:
- for($post_nr = 0; $post_nr < $post_rows; $post_nr++ )
- {
- print ".";
- flush();
-
- $post_id = $rowset[$post_nr]['post_id'];
-
- $search->index('post', $rowset[$post_nr]['post_id'], $rowset[$post_nr]['post_text'], $rowset[$post_nr]['post_subject'], $rowset[$post_nr]['poster_id']);
- }
- // $sql = "UNLOCK TABLES";
- // $result = $db->sql_query($sql);
-
- }
-}
-
-print "
Removing common words (words that appear in more than 50% of the posts)
\n";
-flush();
-$search->tidy();
-print "Removed words that where too common.
";
-
-echo "
Done";
-
-?>
-
-
-
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php
index d136994ba9..deaa28e743 100644
--- a/phpBB/includes/acp/acp_search.php
+++ b/phpBB/includes/acp/acp_search.php
@@ -149,66 +149,49 @@ class acp_search
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_SEARCH');
}
- if (isset($cfg_array['search_type']) && in_array($cfg_array['search_type'], $search_types, true) && ($cfg_array['search_type'] != $config['search_type']))
+ if (isset($cfg_array['search_type']) && ($cfg_array['search_type'] != $config['search_type']))
{
- $search = null;
- $error = false;
-
- if (!$this->init_search($cfg_array['search_type'], $search, $error))
+ $search_backend_factory = $phpbb_container->get('search.backend_factory');
+ $search = $search_backend_factory->get($cfg_array['search_type']);
+ if (confirm_box(true))
{
- if (confirm_box(true))
+ if (!method_exists($search, 'init') || !($error = $search->init()))
{
- if (!method_exists($search, 'init') || !($error = $search->init()))
- {
- $config->set('search_type', $cfg_array['search_type']);
+ $config->set('search_type', $cfg_array['search_type']);
- if (!$updated)
- {
- $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_SEARCH');
- }
- $extra_message = '
' . $user->lang['SWITCHED_SEARCH_BACKEND'] . '
» ' . $user->lang['GO_TO_SEARCH_INDEX'] . '';
- }
- else
+ if (!$updated)
{
- trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
+ $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_SEARCH');
}
+ $extra_message = '
' . $user->lang['SWITCHED_SEARCH_BACKEND'] . '
» ' . $user->lang['GO_TO_SEARCH_INDEX'] . '';
}
else
{
- confirm_box(false, $user->lang['CONFIRM_SEARCH_BACKEND'], build_hidden_fields(array(
- 'i' => $id,
- 'mode' => $mode,
- 'submit' => true,
- 'updated' => $updated,
- 'config' => array('search_type' => $cfg_array['search_type']),
- )));
+ trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
}
}
else
{
- trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
+ confirm_box(false, $user->lang['CONFIRM_SEARCH_BACKEND'], build_hidden_fields(array(
+ 'i' => $id,
+ 'mode' => $mode,
+ 'submit' => true,
+ 'updated' => $updated,
+ 'config' => array('search_type' => $cfg_array['search_type']),
+ )));
}
}
- $search = null;
- $error = false;
- if (!$this->init_search($config['search_type'], $search, $error))
+ if ($updated)
{
- if ($updated)
+ if (method_exists($search, 'config_updated'))
{
- if (method_exists($search, 'config_updated'))
+ if ($search->config_updated())
{
- if ($search->config_updated())
- {
- trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
- }
+ trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
}
}
}
- else
- {
- trigger_error($error . adm_back_link($this->u_action), E_USER_WARNING);
- }
trigger_error($user->lang['CONFIG_UPDATED'] . $extra_message . adm_back_link($this->u_action));
}
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index 9fa5b2524e..b835dff45a 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -275,7 +275,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_block_size'
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_gc', '7200');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_interval', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_store_results', '1800');
-INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_type', '\phpbb\search\backend\fulltext_native');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_type', 'phpbb\search\backend\fulltext_native');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_allow_deny', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_allow_empty_referer', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('secure_downloads', '0');
diff --git a/phpBB/phpbb/search/backend/fulltext_native.php b/phpBB/phpbb/search/backend/fulltext_native.php
index 42c5bc7679..99f47f8b9c 100644
--- a/phpBB/phpbb/search/backend/fulltext_native.php
+++ b/phpBB/phpbb/search/backend/fulltext_native.php
@@ -1735,7 +1735,7 @@ class fulltext_native extends base implements search_backend_interface
$totaltime = microtime(true) - $starttime;
$rows_per_second = $row_count / $totaltime;
meta_refresh(1, $u_action);
- trigger_error($user->lang('SEARCH_INDEX_CREATE_REDIRECT', (int) $row_count, $post_counter) . $user->lang('SEARCH_INDEX_CREATE_REDIRECT_RATE', $rows_per_second));
+ trigger_error($this->user->lang('SEARCH_INDEX_CREATE_REDIRECT', (int) $row_count, $post_counter) . $this->user->lang('SEARCH_INDEX_CREATE_REDIRECT_RATE', $rows_per_second));
}
}
diff --git a/phpBB/phpbb/search/search_backend_factory.php b/phpBB/phpbb/search/search_backend_factory.php
index 636c8f823f..ab103cae73 100644
--- a/phpBB/phpbb/search/search_backend_factory.php
+++ b/phpBB/phpbb/search/search_backend_factory.php
@@ -15,24 +15,25 @@ namespace phpbb\search;
use phpbb\config\config;
use phpbb\di\service_collection;
+use phpbb\search\backend\search_backend_interface;
class search_backend_factory
{
/**
- * @var \phpbb\config\config
+ * @var config
*/
protected $config;
/**
- * @var \phpbb\di\service_collection
+ * @var service_collection
*/
protected $search_backends;
/**
* Constructor
*
- * @param \phpbb\config\config $config
- * @param \phpbb\di\service_collection $search_backends
+ * @param config $config
+ * @param service_collection $search_backends
*/
public function __construct(config $config, service_collection $search_backends)
{
@@ -45,7 +46,7 @@ class search_backend_factory
*
* @param string $class
*
- * @return \phpbb\search\backend\search_backend_interface
+ * @return search_backend_interface
*/
public function get($class)
{
@@ -55,7 +56,7 @@ class search_backend_factory
/**
* Obtains active search backend
*
- * @return \phpbb\search\backend\search_backend_interface
+ * @return search_backend_interface
*/
public function get_active()
{
diff --git a/phpBB/search.php b/phpBB/search.php
index bd7532fc07..3eac7391ed 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -295,7 +295,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
// Select which method we'll use to obtain the post_id or topic_id information
$search_backend_factory = $phpbb_container->get('search.backend_factory');
- $search = $search_backend_factory->get_search();
+ $search = $search_backend_factory->get_active();
// let the search module split up the keywords
if ($keywords)
diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php
index 5a646bb57e..009a817766 100644
--- a/tests/content_visibility/delete_post_test.php
+++ b/tests/content_visibility/delete_post_test.php
@@ -323,6 +323,11 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
// Works as a workaround for tests
$phpbb_container->set('attachment.manager', $attachment_delete);
+ $search_backend = $this->createMock(\phpbb\search\backend\search_backend_interface::class);
+ $search_backend_factory = $this->createMock(\phpbb\search\search_backend_factory::class);
+ $search_backend_factory->method('get_active')->willReturn($search_backend);
+ $phpbb_container->set('search.backend_factory', $search_backend_factory);
+
delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason);
$result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason
diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php
index a96817c67c..76a0aa50ce 100644
--- a/tests/functions_user/delete_user_test.php
+++ b/tests/functions_user/delete_user_test.php
@@ -54,6 +54,13 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
'auth.provider_collection',
$provider_collection
);
+
+ $search_backend = $this->createMock(\phpbb\search\backend\search_backend_interface::class);
+ $search_backend_factory = $this->createMock(\phpbb\search\search_backend_factory::class);
+ $search_backend_factory->method('get_active')->willReturn($search_backend);
+ $phpbb_container->set('search.backend_factory', $search_backend_factory);
+
+
$phpbb_container->setParameter('tables.auth_provider_oauth_token_storage', 'phpbb_oauth_tokens');
$phpbb_container->setParameter('tables.auth_provider_oauth_states', 'phpbb_oauth_states');
$phpbb_container->setParameter('tables.auth_provider_oauth_account_assoc', 'phpbb_oauth_accounts');