[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
This commit is contained in:
David King 2012-10-21 16:09:43 -04:00 committed by Igor Wiedler
parent ad3edf505a
commit cb2725dd5a
8 changed files with 856 additions and 50 deletions

View file

@ -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
);

750
phpBB/composer.lock generated
View file

@ -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": [

View file

@ -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:

View file

@ -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
);

View file

@ -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;
}
}

View file

@ -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);

View file

@ -0,0 +1,38 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
class phpbb_di_pass_cron implements CompilerPassInterface
{
/**
* Modify the container before it is passed to the rest of the code
*
* @param ContainerBuilder $container ContainerBuilder object
* @return null
*/
public function process(ContainerBuilder $container)
{
$definition = $container->getDefinition('cron.task_collection');
foreach ($container->findTaggedServiceIds('cron.task') as $id => $data)
{
$definition->addMethodCall('offsetSet', array(null, $id));
}
}
}

View file

@ -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
);