diff --git a/phpBB/config/default/container/services_console.yml b/phpBB/config/default/container/services_console.yml index ff29a83e22..f23d205b8f 100644 --- a/phpBB/config/default/container/services_console.yml +++ b/phpBB/config/default/container/services_console.yml @@ -259,7 +259,6 @@ services: console.command.searchindex.create: class: phpbb\console\command\searchindex\create arguments: - - '@config' - '@language' - '@log' - '@post.helper' @@ -272,7 +271,6 @@ services: console.command.searchindex.delete: class: phpbb\console\command\searchindex\delete arguments: - - '@config' - '@language' - '@log' - '@post.helper' diff --git a/phpBB/language/en/acp/search.php b/phpBB/language/en/acp/search.php index a79c67fd8e..183ccf0d7b 100644 --- a/phpBB/language/en/acp/search.php +++ b/phpBB/language/en/acp/search.php @@ -91,6 +91,8 @@ $lang = array_merge($lang, array( 'GENERAL_SEARCH_SETTINGS' => 'General search settings', 'GO_TO_SEARCH_INDEX' => 'Go to search index page', + 'INVALID_ACTION' => 'Invalid action', + 'INDEX_STATS' => 'Index statistics', 'INDEXING_IN_PROGRESS' => 'Indexing in progress', 'INDEXING_IN_PROGRESS_EXPLAIN' => 'The search backend is currently indexing all posts on the board. This can take from a few minutes to a few hours depending on your board’s size.', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 6a10e8b846..8333755f87 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -215,6 +215,9 @@ $lang = array_merge($lang, array( 2 => 'Downloaded %d times', ), + 'DI_SERVICE_NOT_FOUND' => 'No service found for class "%s" in collection.', + 'DI_MULTIPLE_SERVICE_DEFINITIONS' => 'More than one service definitions found for class "%s" in collection.', + 'EDIT_POST' => 'Edit post', 'ELLIPSIS' => '…', 'EMAIL' => 'Email', // Short form for EMAIL_ADDRESS @@ -715,6 +718,7 @@ $lang = array_merge($lang, array( 'SEARCH_UNANSWERED' => 'Unanswered topics', 'SEARCH_UNREAD' => 'Unread posts', 'SEARCH_USER_POSTS' => 'Search user’s posts', + 'SEARCH_BACKEND_NOT_FOUND' => 'No search backend could be found.', 'SECONDS' => 'Seconds', 'SEE_ALL' => 'See All', 'SELECT' => 'Select', diff --git a/phpBB/phpbb/console/command/searchindex/list_all.php b/phpBB/phpbb/console/command/searchindex/list_all.php index 566efc1921..d23f46ea20 100644 --- a/phpBB/phpbb/console/command/searchindex/list_all.php +++ b/phpBB/phpbb/console/command/searchindex/list_all.php @@ -82,7 +82,7 @@ class list_all extends command foreach ($this->search_backend_collection as $search_backend) { $name = $search_backend->get_type(); - $active = ($name === $this->config['search_type']) ? '(' . $this->language->lang('$') . ') ' : ''; + $active = ($name === $this->config['search_type']) ? '(' . $this->language->lang('ACTIVE') . ') ' : ''; $search_backends[] = '' . $name . ' ' . $active . $search_backend->get_name(); if ($name === $this->config['search_type'] && !$search_backend->index_created()) diff --git a/phpBB/phpbb/cron/task/core/tidy_search.php b/phpBB/phpbb/cron/task/core/tidy_search.php index d3f5d41bc0..a29a403627 100644 --- a/phpBB/phpbb/cron/task/core/tidy_search.php +++ b/phpBB/phpbb/cron/task/core/tidy_search.php @@ -15,6 +15,7 @@ namespace phpbb\cron\task\core; use phpbb\config\config; use phpbb\cron\task\base; +use phpbb\di\exception\di_exception; use phpbb\search\backend\search_backend_interface; use phpbb\search\search_backend_factory; @@ -88,7 +89,7 @@ class tidy_search extends base $this->active_search = $this->search_backend_factory->get_active(); } } - catch (\RuntimeException $e) + catch (di_exception $e) { return false; } diff --git a/phpBB/phpbb/di/exception/di_exception.php b/phpBB/phpbb/di/exception/di_exception.php new file mode 100644 index 0000000000..957e4f1b81 --- /dev/null +++ b/phpBB/phpbb/di/exception/di_exception.php @@ -0,0 +1,21 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\di\exception; + +use phpbb\exception\runtime_exception; + +class di_exception extends runtime_exception +{ + +} diff --git a/phpBB/phpbb/di/exception/multiple_service_definitions_exception.php b/phpBB/phpbb/di/exception/multiple_service_definitions_exception.php new file mode 100644 index 0000000000..66dc71489e --- /dev/null +++ b/phpBB/phpbb/di/exception/multiple_service_definitions_exception.php @@ -0,0 +1,8 @@ +offsetGet($service_id); diff --git a/phpBB/phpbb/search/search_backend_factory.php b/phpBB/phpbb/search/search_backend_factory.php index deabbdaba7..019d3f6804 100644 --- a/phpBB/phpbb/search/search_backend_factory.php +++ b/phpBB/phpbb/search/search_backend_factory.php @@ -14,10 +14,10 @@ namespace phpbb\search; use phpbb\config\config; +use phpbb\di\exception\service_not_found_exception; use phpbb\di\service_collection; use phpbb\search\backend\search_backend_interface; use phpbb\search\exception\no_search_backend_found_exception; -use RuntimeException; class search_backend_factory { @@ -58,16 +58,9 @@ class search_backend_factory { $search = $this->search_backends->get_by_class($class); } - catch (RuntimeException $e) + catch (service_not_found_exception $e) { - if (strpos($e->getMessage(), 'No service found') === 0) - { - throw new no_search_backend_found_exception(); - } - else - { - throw $e; - } + throw new no_search_backend_found_exception('SEARCH_BACKEND_NOT_FOUND', [], $e); } return $search; diff --git a/phpBB/phpbb/search/state_helper.php b/phpBB/phpbb/search/state_helper.php index 4380d43980..809ac38fe7 100644 --- a/phpBB/phpbb/search/state_helper.php +++ b/phpBB/phpbb/search/state_helper.php @@ -113,7 +113,7 @@ class state_helper // Make sure the action is correct (just in case) if (!in_array($action, ['create', 'delete'])) { - throw new search_exception('Invalid action'); + throw new search_exception('INVALID_ACTION'); } $state = [