From abb8a2892d862c097285ee7f300d12c32428e12c Mon Sep 17 00:00:00 2001 From: LEZY Thomas Date: Tue, 27 May 2014 12:36:44 +0200 Subject: [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 --- phpBB/phpbb/console/command/cron/execute_all.php | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 phpBB/phpbb/console/command/cron/execute_all.php (limited to 'phpBB/phpbb/console/command') 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 @@ +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('' . $this->user->lang('CRON_LOCK_ERROR') . ''); + } + } +} + -- cgit v1.2.1