From cb2725dd5a04118de8628e10f940e926f4fa8fa1 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 21 Oct 2012 16:09:43 -0400 Subject: [PATCH] [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 --- phpBB/common.php | 5 +- phpBB/composer.lock | 750 ++++++++++++++++++++++-- phpBB/config/services.yml | 4 + phpBB/download/file.php | 5 +- phpBB/includes/cron/task/collection.php | 72 +++ phpBB/includes/cron/task/provider.php | 27 +- phpBB/includes/di/pass/cron.php | 38 ++ phpBB/install/database_update.php | 5 +- 8 files changed, 856 insertions(+), 50 deletions(-) create mode 100644 phpBB/includes/cron/task/collection.php create mode 100644 phpBB/includes/di/pass/cron.php diff --git a/phpBB/common.php b/phpBB/common.php index fce08f3834..6a7def1884 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -104,8 +104,9 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array(), - $phpbb_root_path . 'config.' . $phpEx, + array( + new phpbb_di_pass_cron(), + ), $phpbb_root_path, $phpEx ); diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 6b0d3584d1..44c2723842 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -1,67 +1,749 @@ { - "hash": "1632798bc1d5298a4f5bd3087c972a9f", + "hash": "f83c386aaaf04acc7fd1724dd46c0127", "packages": [ { - "package": "symfony/config", - "version": "v2.1.0-RC1" + "name": "symfony/config", + "version": "v2.1.2", + "target-dir": "Symfony/Component/Config", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Config/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-08-22 06:48:41", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Config": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/dependency-injection", - "version": "v2.1.0-RC1" + "name": "symfony/dependency-injection", + "version": "v2.1.2", + "target-dir": "Symfony/Component/DependencyInjection", + "source": { + "type": "git", + "url": "https://github.com/symfony/DependencyInjection", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/DependencyInjection/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/yaml": "2.1.*", + "symfony/config": "2.1.*" + }, + "suggest": { + "symfony/yaml": "2.1.*", + "symfony/config": "2.1.*" + }, + "time": "2012-09-17 13:41:57", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\DependencyInjection": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony DependencyInjection Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/event-dispatcher", - "version": "v2.1.0-RC1" + "name": "symfony/event-dispatcher", + "version": "v2.1.2", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/EventDispatcher/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/dependency-injection": "2.1.*" + }, + "suggest": { + "symfony/dependency-injection": "2.1.*", + "symfony/http-kernel": "2.1.*" + }, + "time": "2012-09-10 03:53:42", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/yaml", - "version": "v2.1.0-RC1" + "name": "symfony/http-foundation", + "version": "v2.1.2", + "target-dir": "Symfony/Component/HttpFoundation", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpFoundation", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/HttpFoundation/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-09-18 09:09:52", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpFoundation": "", + "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony HttpFoundation Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/http-kernel", + "version": "v2.1.2", + "target-dir": "Symfony/Component/HttpKernel", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpKernel", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/HttpKernel/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/event-dispatcher": "2.1.*", + "symfony/http-foundation": "2.1.*" + }, + "require-dev": { + "symfony/browser-kit": "2.1.*", + "symfony/class-loader": "2.1.*", + "symfony/config": "2.1.*", + "symfony/console": "2.1.*", + "symfony/dependency-injection": "2.1.*", + "symfony/finder": "2.1.*", + "symfony/process": "2.1.*", + "symfony/routing": "2.1.*" + }, + "suggest": { + "symfony/browser-kit": "2.1.*", + "symfony/class-loader": "2.1.*", + "symfony/config": "2.1.*", + "symfony/console": "2.1.*", + "symfony/dependency-injection": "2.1.*", + "symfony/finder": "2.1.*" + }, + "time": "2012-09-20 00:13:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpKernel": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony HttpKernel Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/yaml", + "version": "v2.1.2", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml", + "reference": "v2.1.0-RC2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Yaml/zipball/v2.1.0-RC2", + "reference": "v2.1.0-RC2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-08-22 06:48:41", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com" } ], "packages-dev": [ { - "package": "fabpot/goutte", + "name": "fabpot/goutte", "version": "dev-master", - "alias-pretty-version": "1.0.x-dev", - "alias-version": "1.0.9999999.9999999-dev" + "source": { + "type": "git", + "url": "https://github.com/fabpot/Goutte", + "reference": "e1c3306617e350ac17e7631166fd3fd7d689e8ea" + }, + "dist": { + "type": "zip", + "url": "https://github.com/fabpot/Goutte/zipball/e1c3306617e350ac17e7631166fd3fd7d689e8ea", + "reference": "e1c3306617e350ac17e7631166fd3fd7d689e8ea", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "symfony/browser-kit": "2.1.*", + "symfony/css-selector": "2.1.*", + "symfony/dom-crawler": "2.1.*", + "symfony/finder": "2.1.*", + "symfony/process": "2.1.*", + "ext-curl": "*", + "guzzle/http": "2.8.*" + }, + "time": "1349861753", + "type": "application", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "source", + "autoload": { + "psr-0": { + "Goutte": "." + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "A simple PHP Web Scraper", + "homepage": "https://github.com/fabpot/Goutte", + "keywords": [ + "scraper" + ] }, { - "package": "fabpot/goutte", - "version": "dev-master", - "source-reference": "6d26279344736f6983a969e46afef082ebf30a67", - "commit-date": "1345141401" + "name": "guzzle/common", + "version": "v2.8.8", + "target-dir": "Guzzle/Common", + "source": { + "type": "git", + "url": "git://github.com/guzzle/common.git", + "reference": "v2.8.8" + }, + "dist": { + "type": "zip", + "url": "https://github.com/guzzle/common/zipball/v2.8.8", + "reference": "v2.8.8", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "symfony/event-dispatcher": "2.1.*" + }, + "time": "2012-10-15 17:42:47", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Guzzle\\Common": "" + } + }, + "license": [ + "MIT" + ], + "description": "Common libraries used by Guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "log", + "event", + "cache", + "validation", + "Socket", + "common", + "batch", + "inflection" + ] }, { - "package": "guzzle/common", - "version": "v2.8.4" + "name": "guzzle/http", + "version": "v2.8.8", + "target-dir": "Guzzle/Http", + "source": { + "type": "git", + "url": "git://github.com/guzzle/http.git", + "reference": "v2.8.8" + }, + "dist": { + "type": "zip", + "url": "https://github.com/guzzle/http/zipball/v2.8.8", + "reference": "v2.8.8", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "guzzle/common": "self.version", + "guzzle/parser": "self.version" + }, + "time": "2012-10-15 17:42:47", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Guzzle\\Http": "" + } + }, + "license": [ + "MIT" + ], + "description": "HTTP libraries used by Guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "curl", + "http", + "http client", + "client", + "Guzzle" + ] }, { - "package": "guzzle/http", - "version": "v2.8.4" + "name": "guzzle/parser", + "version": "v2.8.8", + "target-dir": "Guzzle/Parser", + "source": { + "type": "git", + "url": "git://github.com/guzzle/parser.git", + "reference": "v2.8.8" + }, + "dist": { + "type": "zip", + "url": "https://github.com/guzzle/parser/zipball/v2.8.8", + "reference": "v2.8.8", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2012-09-20 13:28:06", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Guzzle\\Parser": "" + } + }, + "license": [ + "MIT" + ], + "description": "Interchangeable parsers used by Guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "http", + "url", + "message", + "cookie", + "URI Template" + ] }, { - "package": "guzzle/parser", - "version": "v2.8.4" + "name": "symfony/browser-kit", + "version": "v2.1.2", + "target-dir": "Symfony/Component/BrowserKit", + "source": { + "type": "git", + "url": "https://github.com/symfony/BrowserKit", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/BrowserKit/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/dom-crawler": "2.1.*" + }, + "require-dev": { + "symfony/process": "2.1.*", + "symfony/css-selector": "2.1.*" + }, + "suggest": { + "symfony/process": "2.1.*" + }, + "time": "2012-09-10 03:53:42", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\BrowserKit": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony BrowserKit Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/browser-kit", - "version": "v2.1.0-RC1" + "name": "symfony/css-selector", + "version": "v2.1.2", + "target-dir": "Symfony/Component/CssSelector", + "source": { + "type": "git", + "url": "https://github.com/symfony/CssSelector", + "reference": "v2.1.0-RC2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/CssSelector/zipball/v2.1.0-RC2", + "reference": "v2.1.0-RC2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-08-22 06:48:41", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\CssSelector": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony CssSelector Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/css-selector", - "version": "v2.1.0-RC1" + "name": "symfony/dom-crawler", + "version": "v2.1.2", + "target-dir": "Symfony/Component/DomCrawler", + "source": { + "type": "git", + "url": "https://github.com/symfony/DomCrawler", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/DomCrawler/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/css-selector": "2.1.*" + }, + "suggest": { + "symfony/css-selector": "2.1.*" + }, + "time": "2012-09-10 03:53:42", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\DomCrawler": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony DomCrawler Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/dom-crawler", - "version": "v2.1.0-RC1" + "name": "symfony/finder", + "version": "v2.1.2", + "target-dir": "Symfony/Component/Finder", + "source": { + "type": "git", + "url": "https://github.com/symfony/Finder", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Finder/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-08-22 06:48:41", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Finder": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "http://symfony.com" }, { - "package": "symfony/finder", - "version": "v2.1.0-RC1" - }, - { - "package": "symfony/process", - "version": "v2.1.0-RC1" + "name": "symfony/process", + "version": "v2.1.2", + "target-dir": "Symfony/Component/Process", + "source": { + "type": "git", + "url": "https://github.com/symfony/Process", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Process/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-09-18 15:37:29", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Process": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "http://symfony.com" } ], "aliases": [ diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 6c904ac2c8..b77c3d6c3f 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -47,8 +47,12 @@ services: cron.task_provider: class: phpbb_cron_task_provider arguments: + - @cron.task_collection - @service_container + cron.task_collection: + class: phpbb_cron_task_collection + cron.manager: class: phpbb_cron_manager arguments: diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 3e71bf9961..7ffd335daa 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -63,8 +63,9 @@ if (isset($_GET['avatar'])) new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array(), - $phpbb_root_path . 'config.' . $phpEx, + array( + new phpbb_di_pass_cron(), + ), $phpbb_root_path, $phpEx ); 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 @@ +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); diff --git a/phpBB/includes/di/pass/cron.php b/phpBB/includes/di/pass/cron.php new file mode 100644 index 0000000000..b5fc4af9fc --- /dev/null +++ b/phpBB/includes/di/pass/cron.php @@ -0,0 +1,38 @@ +getDefinition('cron.task_collection'); + + foreach ($container->findTaggedServiceIds('cron.task') as $id => $data) + { + $definition->addMethodCall('offsetSet', array(null, $id)); + } + } +} diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3d296545b4..1734272486 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,8 +121,9 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array(), - $phpbb_root_path . 'config.' . $phpEx, + array( + new phpbb_di_pass_cron(), + ), $phpbb_root_path, $phpEx );