diff options
author | David King <imkingdavid@gmail.com> | 2012-10-21 16:09:43 -0400 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2012-11-10 11:40:49 +0100 |
commit | cb2725dd5a04118de8628e10f940e926f4fa8fa1 (patch) | |
tree | cb79bf44756d029efe62cde8d3d98cf1ae00b5a3 /phpBB/includes/cron/task | |
parent | ad3edf505a9e9ef7f139b033f70a1106539ce0de (diff) | |
download | forums-cb2725dd5a04118de8628e10f940e926f4fa8fa1.tar forums-cb2725dd5a04118de8628e10f940e926f4fa8fa1.tar.gz forums-cb2725dd5a04118de8628e10f940e926f4fa8fa1.tar.bz2 forums-cb2725dd5a04118de8628e10f940e926f4fa8fa1.tar.xz forums-cb2725dd5a04118de8628e10f940e926f4fa8fa1.zip |
[feature/compiled-dic] Fix cron task loading
We cannot use container tags at run time if we are using a cached, compiled
container object (i.e. phpbb_cache_container) so we have to load them
beforehand.
PHPBB3-11152
Diffstat (limited to 'phpBB/includes/cron/task')
-rw-r--r-- | phpBB/includes/cron/task/collection.php | 72 | ||||
-rw-r--r-- | phpBB/includes/cron/task/provider.php | 27 |
2 files changed, 89 insertions, 10 deletions
diff --git a/phpBB/includes/cron/task/collection.php b/phpBB/includes/cron/task/collection.php new file mode 100644 index 0000000000..d05be9012c --- /dev/null +++ b/phpBB/includes/cron/task/collection.php @@ -0,0 +1,72 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Collects cron tasks +* +* @package phpBB3 +*/ +class phpbb_cron_task_collection implements ArrayAccess +{ + /** + * ArrayAccess method + * + * @param mixed $offset Array offset + */ + public function offsetExists($offset) + { + return isset($this->tasks[$offset]); + } + + /** + * ArrayAccess method + * + * @param mixed $offset Array offset + */ + public function offsetGet($offset) + { + return $this->offsetExists($offset) ? $this->tasks[$offset] : null; + } + + /** + * ArrayAccess method + * + * @param mixed $offset Array offset + * @param mixed $value New value + */ + public function offsetSet($offset, $value) + { + if ($offset === null) + { + $this->tasks[] = $value; + } + else + { + $this->tasks[$offset] = $value; + } + } + + /** + * ArrayAccess method + * + * @param mixed $offset Array offset + */ + public function offsetUnset($offset) + { + $this->tasks[$offset] = null; + } +} diff --git a/phpBB/includes/cron/task/provider.php b/phpBB/includes/cron/task/provider.php index 134723ebd1..08e54a651a 100644 --- a/phpBB/includes/cron/task/provider.php +++ b/phpBB/includes/cron/task/provider.php @@ -26,10 +26,11 @@ use Symfony\Component\DependencyInjection\TaggedContainerInterface; */ class phpbb_cron_task_provider implements IteratorAggregate { - private $container; + private $tasks; - public function __construct(TaggedContainerInterface $container) + public function __construct(phpbb_cron_task_collection $tasks, TaggedContainerInterface $container) { + $this->tasks = $tasks; $this->container = $container; } @@ -40,18 +41,24 @@ class phpbb_cron_task_provider implements IteratorAggregate */ public function getIterator() { - $definitions = $this->container->findTaggedServiceIds('cron.task'); - $tasks = array(); - foreach ($definitions as $name => $definition) + foreach ($this->tasks as $names) { - $task = $this->container->get($name); - if ($task instanceof phpbb_cron_task_base) + foreach ($names as $name) { - $task->set_name($name); - } + if (!$this->container->has($name)) + { + continue; + } - $tasks[] = $task; + $task = $this->container->get($name); + if ($task instanceof phpbb_cron_task_base) + { + $task->set_name($name); + } + + $tasks[] = $task; + } } return new ArrayIterator($tasks); |