mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-19 23:32:02 +02:00
[ticket/15540] Trigger errors when search module not found
PHPBB3-15540
This commit is contained in:
parent
cd8c09d0b3
commit
a8de540e93
@ -648,8 +648,22 @@ class acp_main
|
||||
// Warn if no search index is created
|
||||
if ($config['num_posts'])
|
||||
{
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
try
|
||||
{
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
if (strpos($e->getMessage(), 'No service found') === 0)
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$search->index_created())
|
||||
{
|
||||
|
@ -1086,8 +1086,22 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
|
||||
}
|
||||
|
||||
// Remove the message from the search index
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
try
|
||||
{
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
if (strpos($e->getMessage(), 'No service found') === 0)
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$search->index_remove($post_ids, $poster_ids, $forum_ids);
|
||||
|
||||
|
@ -2291,8 +2291,22 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
|
||||
// Index message contents
|
||||
if ($update_search_index && $data_ary['enable_indexing'])
|
||||
{
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
try
|
||||
{
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
if (strpos($e->getMessage(), 'No service found') === 0)
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$search->index($mode, $data_ary['post_id'], $data_ary['message'], $subject, $poster_id, $data_ary['forum_id']);
|
||||
}
|
||||
|
@ -1398,16 +1398,30 @@ function mcp_fork_topic($topic_ids)
|
||||
|
||||
foreach ($topic_data as $topic_id => $topic_row)
|
||||
{
|
||||
if (!isset($search_type) && $topic_row['enable_indexing'])
|
||||
if (!isset($search) && $topic_row['enable_indexing'])
|
||||
{
|
||||
// Select the search method and do some additional checks to ensure it can actually be utilised
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
try
|
||||
{
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
if (strpos($e->getMessage(), 'No service found') === 0)
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
$search_mode = 'post';
|
||||
}
|
||||
else if (!isset($search_type) && !$topic_row['enable_indexing'])
|
||||
else if (!isset($search) && !$topic_row['enable_indexing'])
|
||||
{
|
||||
$search_type = false;
|
||||
$search = false;
|
||||
}
|
||||
|
||||
$sql_ary = array(
|
||||
@ -1589,7 +1603,7 @@ function mcp_fork_topic($topic_ids)
|
||||
// Copy whether the topic is dotted
|
||||
markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']);
|
||||
|
||||
if (!empty($search_type))
|
||||
if (!empty($search))
|
||||
{
|
||||
$search->index($search_mode, $new_post_id, $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id);
|
||||
$search_mode = 'reply'; // After one we index replies
|
||||
|
@ -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 $db, $config, $user, $phpbb_log, $phpbb_dispatcher;
|
||||
global $db, $config, $user, $phpbb_log, $phpbb_dispatcher, $phpbb_container;
|
||||
|
||||
if (empty($userdata) || $userdata['user_id'] == $post_info['user_id'])
|
||||
{
|
||||
@ -632,8 +632,22 @@ function change_poster(&$post_info, $userdata)
|
||||
}
|
||||
|
||||
// refresh search cache of this post
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
try
|
||||
{
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
if (strpos($e->getMessage(), 'No service found') === 0)
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$search->index_remove([], [$post_info['user_id'], $userdata['user_id']], []);
|
||||
|
||||
|
@ -625,8 +625,22 @@ 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_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
try
|
||||
{
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
if (strpos($e->getMessage(), 'No service found') === 0)
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$search->index('edit', $first_post_data['post_id'], $first_post_data['post_text'], $subject, $first_post_data['poster_id'], $first_post_data['forum_id']);
|
||||
}
|
||||
|
@ -294,8 +294,22 @@ 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_active();
|
||||
try
|
||||
{
|
||||
$search_backend_factory = $phpbb_container->get('search.backend_factory');
|
||||
$search = $search_backend_factory->get_active();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
if (strpos($e->getMessage(), 'No service found') === 0)
|
||||
{
|
||||
trigger_error('NO_SUCH_SEARCH_MODULE');
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
// let the search module split up the keywords
|
||||
if ($keywords)
|
||||
|
Loading…
x
Reference in New Issue
Block a user