mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 05:18:52 +00:00
[ticket/14257] Add reparse_lock to CLI command
PHPBB3-14257
This commit is contained in:
parent
8376c6552a
commit
c7ecb1310f
3 changed files with 36 additions and 16 deletions
|
@ -189,6 +189,7 @@ services:
|
||||||
- @user
|
- @user
|
||||||
- @text_reparser_collection
|
- @text_reparser_collection
|
||||||
- @config_text
|
- @config_text
|
||||||
|
- @text_reparser.lock
|
||||||
tags:
|
tags:
|
||||||
- { name: console.command }
|
- { name: console.command }
|
||||||
|
|
||||||
|
|
|
@ -289,6 +289,7 @@ $lang = array_merge($lang, array(
|
||||||
'PROCEED_TO_ACP' => '%sProceed to the ACP%s',
|
'PROCEED_TO_ACP' => '%sProceed to the ACP%s',
|
||||||
|
|
||||||
'REMIND' => 'Remind',
|
'REMIND' => 'Remind',
|
||||||
|
'REPARSE_LOCK_ERROR' => 'Could not obtain reparse lock.',
|
||||||
'RESYNC' => 'Resynchronise',
|
'RESYNC' => 'Resynchronise',
|
||||||
|
|
||||||
'RUNNING_TASK' => 'Running task: %s.',
|
'RUNNING_TASK' => 'Running task: %s.',
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
namespace phpbb\console\command\reparser;
|
namespace phpbb\console\command\reparser;
|
||||||
|
|
||||||
|
use phpbb\exception\runtime_exception;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
@ -41,6 +42,11 @@ class reparse extends \phpbb\console\command\command
|
||||||
*/
|
*/
|
||||||
protected $output;
|
protected $output;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \phpbb\lock\db
|
||||||
|
*/
|
||||||
|
protected $reparse_lock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \phpbb\di\service_collection
|
* @var \phpbb\di\service_collection
|
||||||
*/
|
*/
|
||||||
|
@ -57,13 +63,15 @@ class reparse extends \phpbb\console\command\command
|
||||||
* @param \phpbb\user $user
|
* @param \phpbb\user $user
|
||||||
* @param \phpbb\di\service_collection $reparsers
|
* @param \phpbb\di\service_collection $reparsers
|
||||||
* @param \phpbb\config\db_text $config_text
|
* @param \phpbb\config\db_text $config_text
|
||||||
|
* @param \phpbb\lock\db $reparse_lock
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\user $user, \phpbb\di\service_collection $reparsers, \phpbb\config\db_text $config_text)
|
public function __construct(\phpbb\user $user, \phpbb\di\service_collection $reparsers, \phpbb\config\db_text $config_text, \phpbb\lock\db $reparse_lock)
|
||||||
{
|
{
|
||||||
require_once __DIR__ . '/../../../../includes/functions_content.php';
|
require_once __DIR__ . '/../../../../includes/functions_content.php';
|
||||||
|
|
||||||
$this->config_text = $config_text;
|
$this->config_text = $config_text;
|
||||||
$this->reparsers = $reparsers;
|
$this->reparsers = $reparsers;
|
||||||
|
$this->reparse_lock = $reparse_lock;
|
||||||
parent::__construct($user);
|
parent::__construct($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +171,9 @@ class reparse extends \phpbb\console\command\command
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
$this->io = new SymfonyStyle($input, $output);
|
$this->io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
if (!$this->reparse_lock->acquire())
|
||||||
|
{
|
||||||
$this->load_resume_data();
|
$this->load_resume_data();
|
||||||
|
|
||||||
$name = $input->getArgument('reparser-name');
|
$name = $input->getArgument('reparser-name');
|
||||||
|
@ -185,8 +196,15 @@ class reparse extends \phpbb\console\command\command
|
||||||
|
|
||||||
$this->io->success($this->user->lang('CLI_REPARSER_REPARSE_SUCCESS'));
|
$this->io->success($this->user->lang('CLI_REPARSER_REPARSE_SUCCESS'));
|
||||||
|
|
||||||
|
$this->reparse_lock->release();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new runtime_exception('REPARSE_LOCK_ERROR', array(), null, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an option value, adjusted for given reparser
|
* Get an option value, adjusted for given reparser
|
||||||
|
|
Loading…
Add table
Reference in a new issue