1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-07 01:06:48 +02:00

[ticket/15540] Refactor search backend classes to Symfony services

PHPBB3-15540
This commit is contained in:
Ruben Calvo
2018-11-07 06:21:46 +00:00
committed by rubencm
parent 271d6d3169
commit 2aabf560b4
36 changed files with 567 additions and 522 deletions

View File

@@ -1401,15 +1401,8 @@ function mcp_fork_topic($topic_ids)
if (!isset($search_type) && $topic_row['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);
$search_backend_factory = $phpbb_container->get('search.backend_factory');
$search = $search_backend_factory->get_active();
$search_mode = 'post';
if ($error)

View File

@@ -561,7 +561,7 @@ function phpbb_get_num_ips_for_poster(\phpbb\db\driver\driver_interface $db, $po
*/
function change_poster(&$post_info, $userdata)
{
global $auth, $db, $config, $phpbb_root_path, $phpEx, $user, $phpbb_log, $phpbb_dispatcher;
global $db, $config, $user, $phpbb_log, $phpbb_dispatcher;
if (empty($userdata) || $userdata['user_id'] == $post_info['user_id'])
{
@@ -632,18 +632,12 @@ function change_poster(&$post_info, $userdata)
}
// refresh search cache of this post
$search_type = $config['search_type'];
$search_backend_factory = $phpbb_container->get('search.backend_factory');
$search = $search_backend_factory->get_active();
if (class_exists($search_type))
if (method_exists($search, 'destroy_cache'))
{
// We do some additional checks in the module to ensure it can actually be utilised
$error = false;
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
if (!$error && method_exists($search, 'destroy_cache'))
{
$search->destroy_cache(array(), array($post_info['user_id'], $userdata['user_id']));
}
$search->destroy_cache(array(), array($post_info['user_id'], $userdata['user_id']));
}
$from_username = $post_info['username'];

View File

@@ -428,7 +428,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, $phpbb_dispatcher;
global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config, $phpbb_log, $request;
$post_id_list = $request->variable('post_id_list', array(0));
$forum_id = $request->variable('forum_id', 0);
@@ -625,20 +625,8 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
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_backend_factory = $phpbb_container->get('search.backend_factory');
$search = $search_backend_factory->get_active();
$search->index('edit', $first_post_data['post_id'], $first_post_data['post_text'], $subject, $first_post_data['poster_id'], $first_post_data['forum_id']);
}