diff options
Diffstat (limited to 'phpBB/phpbb/console/command')
| -rw-r--r-- | phpBB/phpbb/console/command/cache/purge.php | 17 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/command.php | 10 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/config/command.php | 10 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/config/delete.php | 10 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/config/get.php | 10 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/config/increment.php | 10 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/config/set.php | 10 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/config/set_atomic.php | 10 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/cron/run.php | 176 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/db/migrate.php | 10 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/extension/command.php | 16 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/extension/disable.php | 11 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/extension/enable.php | 11 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/extension/purge.php | 11 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/extension/show.php | 10 | ||||
| -rw-r--r-- | phpBB/phpbb/console/command/fixup/recalculate_email_hash.php | 10 | 
16 files changed, 295 insertions, 47 deletions
| diff --git a/phpBB/phpbb/console/command/cache/purge.php b/phpBB/phpbb/console/command/cache/purge.php index 017bdc5144..1e2adaeb4d 100644 --- a/phpBB/phpbb/console/command/cache/purge.php +++ b/phpBB/phpbb/console/command/cache/purge.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2014 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\cache; @@ -28,13 +32,17 @@ class purge extends \phpbb\console\command\command  	/** @var \phpbb\user */  	protected $user; -	function __construct(\phpbb\cache\driver\driver_interface $cache, \phpbb\db\driver\driver_interface $db, \phpbb\auth\auth $auth, \phpbb\log\log $log, \phpbb\user $user) +	/** @var \phpbb\config\config */ +	protected $config; + +	public function __construct(\phpbb\cache\driver\driver_interface $cache, \phpbb\db\driver\driver_interface $db, \phpbb\auth\auth $auth, \phpbb\log\log $log, \phpbb\user $user, \phpbb\config\config $config)  	{  		$this->cache = $cache;  		$this->db = $db;  		$this->auth = $auth;  		$this->log = $log;  		$this->user = $user; +		$this->config = $config;  		$this->user->add_lang(array('acp/common'));  		parent::__construct();  	} @@ -49,6 +57,7 @@ class purge extends \phpbb\console\command\command  	protected function execute(InputInterface $input, OutputInterface $output)  	{ +		$this->config->increment('assets_version', 1);  		$this->cache->purge();  		// Clear permissions diff --git a/phpBB/phpbb/console/command/command.php b/phpBB/phpbb/console/command/command.php index 6abbdd203c..d3449c0c38 100644 --- a/phpBB/phpbb/console/command/command.php +++ b/phpBB/phpbb/console/command/command.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */ diff --git a/phpBB/phpbb/console/command/config/command.php b/phpBB/phpbb/console/command/config/command.php index b105bc826d..de3fbd7fa7 100644 --- a/phpBB/phpbb/console/command/config/command.php +++ b/phpBB/phpbb/console/command/config/command.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\config; diff --git a/phpBB/phpbb/console/command/config/delete.php b/phpBB/phpbb/console/command/config/delete.php index 9a2d00561d..e29afdbf82 100644 --- a/phpBB/phpbb/console/command/config/delete.php +++ b/phpBB/phpbb/console/command/config/delete.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\config; diff --git a/phpBB/phpbb/console/command/config/get.php b/phpBB/phpbb/console/command/config/get.php index 275c82b53f..0ed2a12608 100644 --- a/phpBB/phpbb/console/command/config/get.php +++ b/phpBB/phpbb/console/command/config/get.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\config; diff --git a/phpBB/phpbb/console/command/config/increment.php b/phpBB/phpbb/console/command/config/increment.php index bc6b63c6ff..64b5d42b9d 100644 --- a/phpBB/phpbb/console/command/config/increment.php +++ b/phpBB/phpbb/console/command/config/increment.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\config; diff --git a/phpBB/phpbb/console/command/config/set.php b/phpBB/phpbb/console/command/config/set.php index 9d471a96ad..fce1edb93e 100644 --- a/phpBB/phpbb/console/command/config/set.php +++ b/phpBB/phpbb/console/command/config/set.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\config; diff --git a/phpBB/phpbb/console/command/config/set_atomic.php b/phpBB/phpbb/console/command/config/set_atomic.php index 03e7a60210..4df2d90722 100644 --- a/phpBB/phpbb/console/command/config/set_atomic.php +++ b/phpBB/phpbb/console/command/config/set_atomic.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\config; diff --git a/phpBB/phpbb/console/command/cron/run.php b/phpBB/phpbb/console/command/cron/run.php new file mode 100644 index 0000000000..1029a2e085 --- /dev/null +++ b/phpBB/phpbb/console/command/cron/run.php @@ -0,0 +1,176 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited +* @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\console\command\cron; + +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class run extends \phpbb\console\command\command +{ +	/** @var \phpbb\cron\manager */ +	protected $cron_manager; + +	/** @var \phpbb\lock\db */ +	protected $lock_db; + +	/** @var \phpbb\user */ +	protected $user; + +	/** +	* Construct method +	* +	* @param \phpbb\cron\manager $cron_manager The cron manager containing +	*		the cron tasks to be executed. +	* @param \phpbb\lock\db $lock_db The lock for accessing database. +	* @param \phobb\user $user The user object (used to get language information) +	*/ +	public function __construct(\phpbb\cron\manager $cron_manager, \phpbb\lock\db $lock_db, \phpbb\user $user) +	{ +		$this->cron_manager = $cron_manager; +		$this->lock_db = $lock_db; +		$this->user = $user; +		parent::__construct(); +	} + +	/** +	* Sets the command name and description +	* +	* @return null +	*/ +	protected function configure() +	{ +		$this +			->setName('cron:run') +			->setDescription($this->user->lang('CLI_DESCRIPTION_CRON_RUN')) +			->addArgument('name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1')) +		; +	} + +	/** +	* Executes the command cron:run. +	* +	* Tries to acquire the cron lock, then if no argument has been given runs all ready cron tasks. +	* If the cron lock can not be obtained, an error message is printed +	*		and the exit status is set to 1. +	* If the verbose option is specified, each start of a task is printed. +	*		Otherwise there is no output. +	* If an argument is given to the command, only the task whose name matches the +	*		argument will be started. If verbose option is specified, +	*		an info message containing the name of the task is printed. +	* If no task matches the argument given, an error message is printed +	*		and the exit status is set to 2. +	* +	* @param InputInterface $input The input stream used to get the argument and verboe option. +	* @param OutputInterface $output The output stream, used for printing verbose-mode and error information. +	* +	* @return int 0 if all is ok, 1 if a lock error occured and 2 if no task matching the argument was found. +	*/ +	protected function execute(InputInterface $input, OutputInterface $output) +	{ +		if ($this->lock_db->acquire()) +		{ +			$task_name = $input->getArgument('name'); +			if ($task_name) +			{ +				$exit_status = $this->run_one($input, $output, $task_name); +			} +			else +			{ +				$exit_status = $this->run_all($input, $output); +			} + +			$this->lock_db->release(); +			return $exit_status; +		} +		else +		{ +			$output->writeln('<error>' . $this->user->lang('CRON_LOCK_ERROR') . '</error>'); +			return 1; +		} +	} + +	/* +	* Executes all ready cron tasks. +	* +	* If verbose mode is set, an info message will be printed if there is no task to +	*		be run, or else for each starting task. +	* +	* @see execute +	* @param InputInterface $input The input stream used to get the argument and verbose option. +	* @param OutputInterface $output The output stream, used for printing verbose-mode and error information. +	* @return int 0 +	*/ +	protected function run_all(InputInterface $input, OutputInterface $output) +	{ +		$run_tasks = $this->cron_manager->find_all_ready_tasks(); + +		if ($run_tasks) +		{ +			foreach ($run_tasks as $task) +			{ +				if ($input->getOption('verbose')) +				{ +					$output->writeln('<info>' . $this->user->lang('RUNNING_TASK', $task->get_name()) . '</info>'); +				} + +				$task->run(); +			} +		} +		else +		{ +			if ($input->getOption('verbose')) +			{ +				$output->writeln('<info>' . $this->user->lang('CRON_NO_TASK') . '</info>'); +			} +		} + +		return 0; +	} + +	/* +	* Executes a given cron task, if it is ready. +	* +	* If there is a task whose name matches $task_name, it is run and 0 is returned. +	*		and if verbose mode is set, print an info message with the name of the task. +	* If there is no task matching $task_name, the function prints an error message +	*		and returns with status 2. +	* +	* @see execute +	* @param string $task_name The name of the task that should be run. +	* @param InputInterface $input The input stream used to get the argument and verbose option. +	* @param OutputInterface $output The output stream, used for printing verbose-mode and error information. +	* @return int 0 if all is well, 2 if no task matches $task_name. +	*/ +	protected function run_one(InputInterface $input, OutputInterface $output, $task_name) +	{ +		$task = $this->cron_manager->find_task($task_name); +		if ($task) +		{ +			if ($input->getOption('verbose')) +			{ +				$output->writeln('<info>' . $this->user->lang('RUNNING_TASK', $task_name) . '</info>'); +			} + +			$task->run(); +			return 0; +		} +		else +		{ +			$output->writeln('<error>' . $this->user->lang('CRON_NO_SUCH_TASK', $task_name) . '</error>'); +			return 2; +		} +	} +} diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index d984ac9e7a..0f74664095 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2014 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\db; diff --git a/phpBB/phpbb/console/command/extension/command.php b/phpBB/phpbb/console/command/extension/command.php index edde7ce2e2..21bb640504 100644 --- a/phpBB/phpbb/console/command/extension/command.php +++ b/phpBB/phpbb/console/command/extension/command.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\extension; @@ -13,9 +17,13 @@ abstract class command extends \phpbb\console\command\command  	/** @var \phpbb\extension\manager */  	protected $manager; -	function __construct(\phpbb\extension\manager $manager) +	/** @var \phpbb\log\log */ +	protected $log; + +	public function __construct(\phpbb\extension\manager $manager, \phpbb\log\log $log)  	{  		$this->manager = $manager; +		$this->log = $log;  		parent::__construct();  	} diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php index e4de70ca34..5f0e74b984 100644 --- a/phpBB/phpbb/console/command/extension/disable.php +++ b/phpBB/phpbb/console/command/extension/disable.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\extension; @@ -40,6 +44,7 @@ class disable extends command  		}  		else  		{ +			$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_DISABLE', time(), array($name));  			$output->writeln("<info>Successfully disabled extension $name</info>");  			return 0;  		} diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php index ee7dae76aa..0cdf26d4db 100644 --- a/phpBB/phpbb/console/command/extension/enable.php +++ b/phpBB/phpbb/console/command/extension/enable.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\extension; @@ -35,6 +39,7 @@ class enable extends command  		if ($this->manager->enabled($name))  		{ +			$this->log->add('admin', ANONYMOUS, '', 'LOG_EXTENSION_ENABLE', time(), array($name));  			$output->writeln("<info>Successfully enabled extension $name</info>");  			return 0;  		} diff --git a/phpBB/phpbb/console/command/extension/purge.php b/phpBB/phpbb/console/command/extension/purge.php index c2e1d2928c..4e57641d83 100644 --- a/phpBB/phpbb/console/command/extension/purge.php +++ b/phpBB/phpbb/console/command/extension/purge.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\extension; @@ -40,6 +44,7 @@ class purge extends command  		}  		else  		{ +			$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_PURGE', time(), array($name));  			$output->writeln("<info>Successfully purge extension $name</info>");  			return 0;  		} diff --git a/phpBB/phpbb/console/command/extension/show.php b/phpBB/phpbb/console/command/extension/show.php index 0f48ac2379..2db1c59e24 100644 --- a/phpBB/phpbb/console/command/extension/show.php +++ b/phpBB/phpbb/console/command/extension/show.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\extension; diff --git a/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php b/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php index 8c520673d9..ec04da4267 100644 --- a/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php +++ b/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php @@ -1,9 +1,13 @@  <?php  /**  * -* @package phpBB3 -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* 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.  *  */  namespace phpbb\console\command\fixup; | 
