aboutsummaryrefslogtreecommitdiff
path: root/phpBB
diff options
context:
space:
mode:
authorMáté Bartus <mate.bartus@gmail.com>2016-04-13 10:11:24 +0200
committerMáté Bartus <mate.bartus@gmail.com>2016-04-13 10:11:24 +0200
commit4c257d47a6e4ddd6a5057b77c83ad78d3b8bd444 (patch)
treef8110622ff6bd52b75a3c2eb6be1fcd37cf96522 /phpBB
parentMerge pull request #4284 from CHItA/ticket/14589 (diff)
parent[ticket/13616] Fix CS + constant in the core extension (diff)
downloadphpbb-4c257d47a6e4ddd6a5057b77c83ad78d3b8bd444.tar.gz
phpbb-4c257d47a6e4ddd6a5057b77c83ad78d3b8bd444.tar.bz2
phpbb-4c257d47a6e4ddd6a5057b77c83ad78d3b8bd444.zip
Merge pull request #4236 from Nicofuma/ticket/13616
[ticket/13616] Uses symfony/proxy-manager-bridge to lazy load twig lexer
Diffstat (limited to 'phpBB')
-rwxr-xr-xphpBB/bin/phpbbcli.php2
-rw-r--r--phpBB/common.php2
-rw-r--r--phpBB/composer.json6
-rw-r--r--phpBB/composer.lock280
-rw-r--r--phpBB/config/default/container/services_twig.yml4
-rw-r--r--phpBB/config/installer/container/services.yml3
-rw-r--r--phpBB/includes/bbcode.php1
-rw-r--r--phpBB/includes/compatibility_globals.php2
-rw-r--r--phpBB/includes/functions_messenger.php1
-rw-r--r--phpBB/phpbb/di/container_builder.php8
-rw-r--r--phpBB/phpbb/di/extension/core.php8
-rw-r--r--phpBB/phpbb/install/helper/container_factory.php3
-rw-r--r--phpBB/phpbb/template/twig/environment.php21
13 files changed, 309 insertions, 32 deletions
diff --git a/phpBB/bin/phpbbcli.php b/phpBB/bin/phpbbcli.php
index 72f1785931..804a7e09a0 100755
--- a/phpBB/bin/phpbbcli.php
+++ b/phpBB/bin/phpbbcli.php
@@ -68,6 +68,8 @@ $phpbb_container = $phpbb_container_builder->get_container();
$phpbb_container->get('request')->enable_super_globals();
require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx);
+register_compatibility_globals();
+
/* @var $user \phpbb\user */
$user = $phpbb_container->get('user');
$user->data['user_id'] = ANONYMOUS;
diff --git a/phpBB/common.php b/phpBB/common.php
index 31972fe521..d12966168b 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -134,6 +134,8 @@ $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx);
+register_compatibility_globals();
+
// Add own hook handler
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
diff --git a/phpBB/composer.json b/phpBB/composer.json
index b0c9b57cb6..3fe1c90718 100644
--- a/phpBB/composer.json
+++ b/phpBB/composer.json
@@ -43,6 +43,7 @@
"symfony/finder": "2.8.*",
"symfony/http-foundation": "2.8.*",
"symfony/http-kernel": "2.8.*",
+ "symfony/proxy-manager-bridge": "2.8.*",
"symfony/routing": "2.8.*",
"symfony/twig-bridge": "2.8.*",
"symfony/yaml": "2.8.*",
@@ -64,5 +65,10 @@
"branch-alias": {
"dev-master": "3.2.x-dev"
}
+ },
+ "config": {
+ "platform": {
+ "php": "5.4"
+ }
}
}
diff --git a/phpBB/composer.lock b/phpBB/composer.lock
index 968447fd63..c6a0c3e854 100644
--- a/phpBB/composer.lock
+++ b/phpBB/composer.lock
@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "9cbb41222e71eb86e0ef9118baafc691",
- "content-hash": "03a990fa2d088c89afe4824d2d53e873",
+ "hash": "b82925c74b2b12ce589973243a9fab68",
+ "content-hash": "fee6d87604f3053b51c0947ded841cfe",
"packages": [
{
"name": "bantu/ini-get-wrapper",
@@ -402,6 +402,69 @@
"time": "2015-08-21 11:40:30"
},
{
+ "name": "ocramius/proxy-manager",
+ "version": "1.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Ocramius/ProxyManager.git",
+ "reference": "57e9272ec0e8deccf09421596e0e2252df440e11"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Ocramius/ProxyManager/zipball/57e9272ec0e8deccf09421596e0e2252df440e11",
+ "reference": "57e9272ec0e8deccf09421596e0e2252df440e11",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "zendframework/zend-code": ">2.2.5,<3.0"
+ },
+ "require-dev": {
+ "ext-phar": "*",
+ "phpunit/phpunit": "~4.0",
+ "squizlabs/php_codesniffer": "1.5.*"
+ },
+ "suggest": {
+ "ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects",
+ "zendframework/zend-json": "To have the JsonRpc adapter (Remote Object feature)",
+ "zendframework/zend-soap": "To have the Soap adapter (Remote Object feature)",
+ "zendframework/zend-stdlib": "To use the hydrator proxy",
+ "zendframework/zend-xmlrpc": "To have the XmlRpc adapter (Remote Object feature)"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "ProxyManager\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Marco Pivetta",
+ "email": "ocramius@gmail.com",
+ "homepage": "http://ocramius.github.com/"
+ }
+ ],
+ "description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies",
+ "homepage": "https://github.com/Ocramius/ProxyManager",
+ "keywords": [
+ "aop",
+ "lazy loading",
+ "proxy",
+ "proxy pattern",
+ "service proxies"
+ ],
+ "time": "2015-08-09 04:28:19"
+ },
+ {
"name": "paragonie/random_compat",
"version": "v1.2.2",
"source": {
@@ -1342,6 +1405,60 @@
"time": "2016-01-20 09:13:37"
},
{
+ "name": "symfony/proxy-manager-bridge",
+ "version": "v2.8.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/proxy-manager-bridge.git",
+ "reference": "713ed53cf1da3f41288c608d2d0ddb44d6b07304"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/proxy-manager-bridge/zipball/713ed53cf1da3f41288c608d2d0ddb44d6b07304",
+ "reference": "713ed53cf1da3f41288c608d2d0ddb44d6b07304",
+ "shasum": ""
+ },
+ "require": {
+ "ocramius/proxy-manager": "~0.4|~1.0|~2.0",
+ "php": ">=5.3.9",
+ "symfony/dependency-injection": "~2.8|~3.0.0"
+ },
+ "require-dev": {
+ "symfony/config": "~2.3|~3.0.0"
+ },
+ "type": "symfony-bridge",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Bridge\\ProxyManager\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony ProxyManager Bridge",
+ "homepage": "https://symfony.com",
+ "time": "2016-03-04 07:54:35"
+ },
+ {
"name": "symfony/routing",
"version": "v2.8.3",
"source": {
@@ -1606,6 +1723,160 @@
"templating"
],
"time": "2016-01-25 21:22:18"
+ },
+ {
+ "name": "zendframework/zend-code",
+ "version": "2.5.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/zendframework/zend-code.git",
+ "reference": "5d998f261ec2a55171c71da57a11622745680153"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/zendframework/zend-code/zipball/5d998f261ec2a55171c71da57a11622745680153",
+ "reference": "5d998f261ec2a55171c71da57a11622745680153",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.23",
+ "zendframework/zend-eventmanager": "~2.5"
+ },
+ "require-dev": {
+ "doctrine/common": ">=2.1",
+ "fabpot/php-cs-fixer": "1.7.*",
+ "phpunit/phpunit": "~4.0",
+ "zendframework/zend-stdlib": "~2.5",
+ "zendframework/zend-version": "~2.5"
+ },
+ "suggest": {
+ "doctrine/common": "Doctrine\\Common >=2.1 for annotation features",
+ "zendframework/zend-stdlib": "Zend\\Stdlib component"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev",
+ "dev-develop": "2.6-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Zend\\Code\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "description": "provides facilities to generate arbitrary code using an object oriented interface",
+ "homepage": "https://github.com/zendframework/zend-code",
+ "keywords": [
+ "code",
+ "zf2"
+ ],
+ "time": "2015-06-03 15:31:59"
+ },
+ {
+ "name": "zendframework/zend-eventmanager",
+ "version": "2.5.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/zendframework/zend-eventmanager.git",
+ "reference": "d94a16039144936f107f906896349900fd634443"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/d94a16039144936f107f906896349900fd634443",
+ "reference": "d94a16039144936f107f906896349900fd634443",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.23",
+ "zendframework/zend-stdlib": "~2.5"
+ },
+ "require-dev": {
+ "fabpot/php-cs-fixer": "1.7.*",
+ "phpunit/phpunit": "~4.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev",
+ "dev-develop": "2.6-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Zend\\EventManager\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "homepage": "https://github.com/zendframework/zend-eventmanager",
+ "keywords": [
+ "eventmanager",
+ "zf2"
+ ],
+ "time": "2015-06-03 15:32:01"
+ },
+ {
+ "name": "zendframework/zend-stdlib",
+ "version": "2.5.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/zendframework/zend-stdlib.git",
+ "reference": "cc8e90a60dd5d44b9730b77d07b97550091da1ae"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/cc8e90a60dd5d44b9730b77d07b97550091da1ae",
+ "reference": "cc8e90a60dd5d44b9730b77d07b97550091da1ae",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.23"
+ },
+ "require-dev": {
+ "fabpot/php-cs-fixer": "1.7.*",
+ "phpunit/phpunit": "~4.0",
+ "zendframework/zend-config": "~2.5",
+ "zendframework/zend-eventmanager": "~2.5",
+ "zendframework/zend-filter": "~2.5",
+ "zendframework/zend-inputfilter": "~2.5",
+ "zendframework/zend-serializer": "~2.5",
+ "zendframework/zend-servicemanager": "~2.5"
+ },
+ "suggest": {
+ "zendframework/zend-eventmanager": "To support aggregate hydrator usage",
+ "zendframework/zend-filter": "To support naming strategy hydrator usage",
+ "zendframework/zend-serializer": "Zend\\Serializer component",
+ "zendframework/zend-servicemanager": "To support hydrator plugin manager usage"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.5-dev",
+ "dev-develop": "2.6-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Zend\\Stdlib\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "homepage": "https://github.com/zendframework/zend-stdlib",
+ "keywords": [
+ "stdlib",
+ "zf2"
+ ],
+ "time": "2015-06-03 15:32:03"
}
],
"packages-dev": [
@@ -3003,5 +3274,8 @@
"platform": {
"php": ">=5.4,<7.1"
},
- "platform-dev": []
+ "platform-dev": [],
+ "platform-overrides": {
+ "php": "5.4"
+ }
}
diff --git a/phpBB/config/default/container/services_twig.yml b/phpBB/config/default/container/services_twig.yml
index dc08d65e1a..3ca6d62c07 100644
--- a/phpBB/config/default/container/services_twig.yml
+++ b/phpBB/config/default/container/services_twig.yml
@@ -8,14 +8,16 @@ services:
- '@config'
- '@filesystem'
- '@path_helper'
- - '@service_container'
- '%core.template.cache_path%'
- '@ext.manager'
- '@template.twig.loader'
- []
+ calls:
+ - [setLexer, ['@template.twig.lexer']]
template.twig.lexer:
class: phpbb\template\twig\lexer
+ lazy: true
arguments:
- '@template.twig.environment'
diff --git a/phpBB/config/installer/container/services.yml b/phpBB/config/installer/container/services.yml
index 97fc1256fd..4c3ed3bfcb 100644
--- a/phpBB/config/installer/container/services.yml
+++ b/phpBB/config/installer/container/services.yml
@@ -81,11 +81,12 @@ services:
- '@config'
- '@filesystem'
- '@path_helper'
- - '@service_container'
- '%core.template.cache_path%'
- null
- '@template.twig.loader'
- []
+ calls:
+ - [setLexer, ['@template.twig.lexer']]
console.exception_subscriber:
class: phpbb\console\exception_subscriber
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index 4b2aa90ebc..e8492a82a3 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -154,7 +154,6 @@ class bbcode
$phpbb_container->get('config'),
$phpbb_container->get('filesystem'),
$phpbb_container->get('path_helper'),
- $phpbb_container,
$phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader(
diff --git a/phpBB/includes/compatibility_globals.php b/phpBB/includes/compatibility_globals.php
index ae532c0f13..dc7a593693 100644
--- a/phpBB/includes/compatibility_globals.php
+++ b/phpBB/includes/compatibility_globals.php
@@ -75,5 +75,3 @@ function register_compatibility_globals()
/* @var $template \phpbb\template\template */
$template = $phpbb_container->get('template');
}
-
-register_compatibility_globals();
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index f55b5e7ec3..3fa96afb29 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -639,7 +639,6 @@ class messenger
$phpbb_container->get('config'),
$phpbb_container->get('filesystem'),
$phpbb_container->get('path_helper'),
- $phpbb_container,
$phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader(
diff --git a/phpBB/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php
index b9284d04be..b6854673c2 100644
--- a/phpBB/phpbb/di/container_builder.php
+++ b/phpBB/phpbb/di/container_builder.php
@@ -14,6 +14,8 @@
namespace phpbb\di;
use phpbb\filesystem\filesystem;
+use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
+use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -460,7 +462,10 @@ class container_builder
{
try
{
- $dumper = new PhpDumper($this->container);
+ $dumper = new PhpDumper($this->container);
+ $proxy_dumper = new ProxyDumper();
+ $dumper->setProxyDumper($proxy_dumper);
+
$cached_container_dump = $dumper->dump(array(
'class' => 'phpbb_cache_container',
'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder',
@@ -483,6 +488,7 @@ class container_builder
protected function create_container(array $extensions)
{
$container = new ContainerBuilder(new ParameterBag($this->get_core_parameters()));
+ $container->setProxyInstantiator(new RuntimeInstantiator());
$extensions_alias = array();
diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php
index c48a80a558..29c0b0e44e 100644
--- a/phpBB/phpbb/di/extension/core.php
+++ b/phpBB/phpbb/di/extension/core.php
@@ -24,6 +24,8 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
*/
class core extends Extension
{
+ const TWIG_OPTIONS_POSITION = 6;
+
/**
* Config path
* @var string
@@ -71,7 +73,7 @@ class core extends Extension
// Set the Twig options if defined in the environment
$definition = $container->getDefinition('template.twig.environment');
- $twig_environment_options = $definition->getArgument(7);
+ $twig_environment_options = $definition->getArgument(static::TWIG_OPTIONS_POSITION);
if ($config['twig']['debug'])
{
$twig_environment_options['debug'] = true;
@@ -81,8 +83,8 @@ class core extends Extension
$twig_environment_options['auto_reload'] = true;
}
- // Replace the 8th argument, the options passed to the environment
- $definition->replaceArgument(7, $twig_environment_options);
+ // Replace the 7th argument, the options passed to the environment
+ $definition->replaceArgument(static::TWIG_OPTIONS_POSITION, $twig_environment_options);
if ($config['twig']['enable_debug_extension'])
{
diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php
index 5cf4f8a283..9e372fecde 100644
--- a/phpBB/phpbb/install/helper/container_factory.php
+++ b/phpBB/phpbb/install/helper/container_factory.php
@@ -183,6 +183,9 @@ class container_factory
// Get compatibilty globals and constants
$this->update_helper->include_file('includes/compatibility_globals.' . $this->php_ext);
+
+ register_compatibility_globals();
+
$this->update_helper->include_file('includes/constants.' . $this->php_ext);
}
}
diff --git a/phpBB/phpbb/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php
index 56c85c8d71..179412a2e3 100644
--- a/phpBB/phpbb/template/twig/environment.php
+++ b/phpBB/phpbb/template/twig/environment.php
@@ -50,20 +50,18 @@ class environment extends \Twig_Environment
* @param \phpbb\config\config $phpbb_config The phpBB configuration
* @param \phpbb\filesystem\filesystem $filesystem
* @param \phpbb\path_helper $path_helper phpBB path helper
- * @param \Symfony\Component\DependencyInjection\ContainerInterface $container The dependency injection container
* @param string $cache_path The path to the cache directory
* @param \phpbb\extension\manager $extension_manager phpBB extension manager
* @param \Twig_LoaderInterface $loader Twig loader interface
* @param array $options Array of options to pass to Twig
*/
- public function __construct(\phpbb\config\config $phpbb_config, \phpbb\filesystem\filesystem $filesystem, \phpbb\path_helper $path_helper, \Symfony\Component\DependencyInjection\ContainerInterface $container, $cache_path, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array())
+ public function __construct(\phpbb\config\config $phpbb_config, \phpbb\filesystem\filesystem $filesystem, \phpbb\path_helper $path_helper, $cache_path, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array())
{
$this->phpbb_config = $phpbb_config;
$this->filesystem = $filesystem;
$this->phpbb_path_helper = $path_helper;
$this->extension_manager = $extension_manager;
- $this->container = $container;
$this->phpbb_root_path = $this->phpbb_path_helper->get_phpbb_root_path();
$this->web_root_path = $this->phpbb_path_helper->get_web_root_path();
@@ -77,25 +75,10 @@ class environment extends \Twig_Environment
'autoescape' => false,
), $options);
- return parent::__construct($loader, $options);
+ parent::__construct($loader, $options);
}
/**
- * {@inheritdoc}
- */
- public function getLexer()
- {
- if (null === $this->lexer)
- {
- $this->lexer = $this->container->get('template.twig.lexer');
- $this->lexer->set_environment($this);
- }
-
- return $this->lexer;
- }
-
-
- /**
* Get the list of enabled phpBB extensions
*
* Used in EVENT node