aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/console/command/cron
diff options
context:
space:
mode:
authorLEZY Thomas <thomas.gif.91@gmail.com>2014-05-27 12:36:44 +0200
committerLEZY Thomas <thomas.gif.91@gmail.com>2014-05-27 18:37:37 +0200
commitabb8a2892d862c097285ee7f300d12c32428e12c (patch)
tree78cdcdbd88ef88aaacef3ccaccb792bd2bdccaab /phpBB/phpbb/console/command/cron
parent1b73c217f0ba80e448bb3f34ffe8ed082fa5e99f (diff)
downloadforums-abb8a2892d862c097285ee7f300d12c32428e12c.tar
forums-abb8a2892d862c097285ee7f300d12c32428e12c.tar.gz
forums-abb8a2892d862c097285ee7f300d12c32428e12c.tar.bz2
forums-abb8a2892d862c097285ee7f300d12c32428e12c.tar.xz
forums-abb8a2892d862c097285ee7f300d12c32428e12c.zip
[ticket/12597] Command for executing all available cron tasks
Command cron:execute-all executes all available cron tasks. Test files in tests/console/cron folder PHPBB3-12597
Diffstat (limited to 'phpBB/phpbb/console/command/cron')
-rw-r--r--phpBB/phpbb/console/command/cron/execute_all.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/phpBB/phpbb/console/command/cron/execute_all.php b/phpBB/phpbb/console/command/cron/execute_all.php
new file mode 100644
index 0000000000..4f0f225e91
--- /dev/null
+++ b/phpBB/phpbb/console/command/cron/execute_all.php
@@ -0,0 +1,65 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+namespace phpbb\console\command\cron;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class execute_all extends \phpbb\console\command\command
+{
+ /** @var \phpbb\cron\manager */
+ protected $cron_manager;
+
+ /** @var \phpbb\lock\db */
+ protected $lock_db;
+
+ /** @var \phpbb\user */
+ protected $user;
+
+ 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();
+ }
+
+ protected function configure()
+ {
+ $this
+ ->setName('cron:execute-all')
+ ->setDescription($this->user->lang('CLI_DESCR_CRON_EXECUTE_ALL'))
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ if ($this->lock_db->acquire())
+ {
+ $run_tasks = $this->cron_manager->find_all_ready_tasks();
+
+ foreach ($run_tasks as $task)
+ {
+ if ($input->getOption('verbose'))
+ {
+ $output->writeln($this->user->lang('RUNNING_TASK', $task->get_name()) . "\n");
+ }
+
+ $task->run();
+ }
+ $this->lock_db->release();
+ }
+ else
+ {
+ $output->writeln('<error>' . $this->user->lang('CRON_LOCK_ERROR') . '</error>');
+ }
+ }
+}
+