[ticket/12683] Code review

PHPBB3-12683
This commit is contained in:
Ruben Calvo 2021-11-30 00:04:46 +01:00
parent 2e917b6059
commit 23ce5121a4
No known key found for this signature in database
11 changed files with 41 additions and 35 deletions

View file

@ -152,7 +152,7 @@ $lang = array_merge($lang, array(
'CLI_SEARCHINDEX_CREATE_FAILURE' => 'Error creating search index',
'CLI_SEARCHINDEX_DELETE_SUCCESS' => 'Search index deleted successfully',
'CLI_SEARCHINDEX_DELETE_FAILURE' => 'Error deleting search index',
'CLI_SEARCHINDEX_ACTION_IN_PROGRESS' => 'There is an action currently in progress. CLI doesnt support incomplete index/delete actions, please solve it from the ACP',
'CLI_SEARCHINDEX_ACTION_IN_PROGRESS' => 'There is an action currently in progress. CLI doesnt support incomplete index/delete actions, please solve it from the ACP.',
'CLI_SEARCHINDEX_ACTIVE_NOT_INDEXED' => 'Active search backend isnt indexed',
// In all the case %1$s is the logical name of the file and %2$s the real name on the filesystem

View file

@ -21,6 +21,7 @@ use phpbb\search\exception\no_search_backend_found_exception;
use phpbb\search\search_backend_factory;
use phpbb\search\state_helper;
use phpbb\user;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -108,13 +109,13 @@ class create extends command
catch (no_search_backend_found_exception $e)
{
$io->error($this->language->lang('CLI_SEARCHINDEX_BACKEND_NOT_FOUND', $search_backend));
return command::FAILURE;
return symfony_command::FAILURE;
}
if ($this->state_helper->is_action_in_progress())
{
$io->error($this->language->lang('CLI_SEARCHINDEX_ACTION_IN_PROGRESS', $search_backend));
return command::FAILURE;
return symfony_command::FAILURE;
}
try
@ -130,7 +131,6 @@ class create extends command
{
$this->state_helper->update_counter($status['post_counter']);
$progress->setMaxSteps($status['max_post_id']);
$progress->setProgress($status['post_counter']);
$progress->setMessage(round($status['rows_per_second'], 2) . ' rows/s');
}
@ -142,7 +142,7 @@ class create extends command
catch (\Exception $e)
{
$io->error($this->language->lang('CLI_SEARCHINDEX_CREATE_FAILURE', $name));
return command::FAILURE;
return symfony_command::FAILURE;
}
$search->tidy();
@ -152,6 +152,6 @@ class create extends command
$this->log->add('admin', ANONYMOUS, '', 'LOG_SEARCH_INDEX_CREATED', false, array($name));
$io->success($this->language->lang('CLI_SEARCHINDEX_CREATE_SUCCESS', $name));
return command::SUCCESS;
return symfony_command::SUCCESS;
}
}

View file

@ -21,6 +21,7 @@ use phpbb\search\exception\no_search_backend_found_exception;
use phpbb\search\search_backend_factory;
use phpbb\search\state_helper;
use phpbb\user;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -108,13 +109,13 @@ class delete extends command
catch (no_search_backend_found_exception $e)
{
$io->error($this->language->lang('CLI_SEARCHINDEX_BACKEND_NOT_FOUND', $search_backend));
return command::FAILURE;
return symfony_command::FAILURE;
}
if ($this->state_helper->is_action_in_progress())
{
$io->error($this->language->lang('CLI_SEARCHINDEX_ACTION_IN_PROGRESS', $search_backend));
return command::FAILURE;
return symfony_command::FAILURE;
}
try
@ -130,7 +131,6 @@ class delete extends command
{
$this->state_helper->update_counter($status['post_counter']);
$progress->setMaxSteps($status['max_post_id']);
$progress->setProgress($status['post_counter']);
$progress->setMessage(round($status['rows_per_second'], 2) . ' rows/s');
}
@ -142,7 +142,7 @@ class delete extends command
catch (\Exception $e)
{
$io->error($this->language->lang('CLI_SEARCHINDEX_DELETE_FAILURE', $name));
return command::FAILURE;
return symfony_command::FAILURE;
}
$search->tidy();
@ -152,6 +152,6 @@ class delete extends command
$this->log->add('admin', ANONYMOUS, '', 'LOG_SEARCH_INDEX_REMOVED', false, array($name));
$io->success($this->language->lang('CLI_SEARCHINDEX_DELETE_SUCCESS', $name));
return command::SUCCESS;
return symfony_command::SUCCESS;
}
}

View file

@ -18,6 +18,7 @@ use phpbb\console\command\command;
use phpbb\di\service_collection;
use phpbb\language\language;
use phpbb\user;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
@ -92,6 +93,6 @@ class list_all extends command
$io->listing($search_backends);
return command::SUCCESS;
return symfony_command::SUCCESS;
}
}

View file

@ -93,19 +93,13 @@ class fulltext_native extends base implements search_backend_interface
*/
protected $phpbb_dispatcher;
/**
* @var language
*/
/** @var language */
protected $language;
/**
* @var string
*/
/** @var string */
protected $search_wordlist_table;
/**
* @var string
*/
/** @var string */
protected $search_wordmatch_table;
/**

View file

@ -44,7 +44,7 @@ class state_helper
}
/**
* Returns if there is an action in progress
* Returns whether there is an action in progress
*
* @return bool
*/
@ -101,7 +101,7 @@ class state_helper
*/
public function init(string $search_type, string $action): void
{
// Is not possible to start a new process when there is one already running
// It's not possible to start a new process when there is one already running
if ($this->is_action_in_progress())
{
throw new action_in_progress_exception();
@ -158,7 +158,7 @@ class state_helper
*/
private function load_state(): array
{
// Is not possible to execute an action over state if is empty
// Is not possible to execute an action over state if it's empty
if (!$this->is_action_in_progress())
{
throw new no_action_in_progress_exception();

View file

@ -5,10 +5,10 @@ use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
require_once __DIR__ . '/base.php';
require_once __DIR__ . '/mock/search_backend_mock.php';
require_once __DIR__ . '/phpbb_console_searchindex_base.php';
require_once __DIR__ . '/../../mock/search_backend_mock.php';
class create_test extends base
class phpbb_console_searchindex_create_test extends phpbb_console_searchindex_base
{
public function get_command_tester()
{

View file

@ -5,10 +5,10 @@ use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
require_once __DIR__ . '/base.php';
require_once __DIR__ . '/mock/search_backend_mock.php';
require_once __DIR__ . '/phpbb_console_searchindex_base.php';
require_once __DIR__ . '/../../mock/search_backend_mock.php';
class delete_test extends base
class phpbb_console_searchindex_delete_test extends phpbb_console_searchindex_base
{
public function get_command_tester()
{

View file

@ -5,10 +5,10 @@ use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
require_once __DIR__ . '/base.php';
require_once __DIR__ . '/mock/search_backend_mock.php';
require_once __DIR__ . '/phpbb_console_searchindex_base.php';
require_once __DIR__ . '/../../mock/search_backend_mock.php';
class list_all_test extends base
class phpbb_console_searchindex_list_all_test extends phpbb_console_searchindex_base
{
public function get_command_tester()
{

View file

@ -1,4 +1,15 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
use phpbb\config\config;
use phpbb\di\service_collection;
@ -9,9 +20,9 @@ use phpbb\search\search_backend_factory;
use phpbb\search\state_helper;
use phpbb\user;
require_once __DIR__ . '/mock/search_backend_mock.php';
require_once __DIR__ . '/../../mock/search_backend_mock.php';
class base extends phpbb_test_case
class phpbb_console_searchindex_base extends phpbb_test_case
{
/** @var config */
protected $config;