From 5cdbef860de6eccbf1ad62390668acc7fbccb46a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 23 Mar 2016 11:26:30 +0100 Subject: [ticket/13616] Uses symfony/proxy-manager-bridge to lazy load twig lexer PHPBB3-13616 --- build/build.xml | 16 ++ phpBB/composer.json | 6 + phpBB/composer.lock | 280 ++++++++++++++++++++++- phpBB/config/default/container/services_twig.yml | 4 +- phpBB/config/installer/container/services.yml | 3 +- phpBB/phpbb/di/container_builder.php | 8 +- phpBB/phpbb/di/extension/core.php | 6 +- phpBB/phpbb/template/twig/environment.php | 21 +- 8 files changed, 316 insertions(+), 28 deletions(-) diff --git a/build/build.xml b/build/build.xml index 7a244e48d9..bc81213e30 100644 --- a/build/build.xml +++ b/build/build.xml @@ -443,6 +443,13 @@ + + + + + + + @@ -473,6 +480,15 @@ + + + + + + + + + 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", @@ -401,6 +401,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", @@ -1341,6 +1404,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", @@ -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/phpbb/di/container_builder.php b/phpBB/phpbb/di/container_builder.php index 7bfe1bbb87..0462fb60c2 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..2faeff3636 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -71,7 +71,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(6); if ($config['twig']['debug']) { $twig_environment_options['debug'] = true; @@ -81,8 +81,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(6, $twig_environment_options); if ($config['twig']['enable_debug_extension']) { 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,24 +75,9 @@ 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 * -- cgit v1.2.1 From 4070d1e06f677ea43b55c04e67b031a96dd22434 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 23 Mar 2016 11:52:28 +0100 Subject: [ticket/13616] Uses a php 5.4 compatible version PHPBB3-13616 --- build/build.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/build.xml b/build/build.xml index bc81213e30..205286c236 100644 --- a/build/build.xml +++ b/build/build.xml @@ -481,14 +481,14 @@ - - - + + + -- cgit v1.2.1 From 663e3bc64238668ec139b53ccfb2f82a1d306601 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 23 Mar 2016 21:59:40 +0100 Subject: [ticket/13616] Updates direct call to twig environment constructor PHPBB3-13616 --- phpBB/includes/bbcode.php | 1 - phpBB/includes/functions_messenger.php | 1 - tests/controller/common_helper_route.php | 3 +-- tests/extension/metadata_manager_test.php | 3 +-- tests/template/template_allfolder_test.php | 3 +-- tests/template/template_events_test.php | 3 +-- tests/template/template_includecss_test.php | 3 +-- tests/template/template_test_case.php | 3 +-- tests/template/template_test_case_with_tree.php | 3 +-- 9 files changed, 7 insertions(+), 16 deletions(-) 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/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/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index c23342bc57..21397d0f77 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -95,7 +95,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->config, $this->filesystem, $this->phpbb_path_helper, - $container, $cache_path, null, $loader, @@ -107,7 +106,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 53bd3d109b..19b99ee0ce 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -65,7 +65,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->config, $filesystem, $phpbb_path_helper, - $container, $cache_path, null, $loader, @@ -112,7 +111,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->user = new \phpbb\user($lang, '\phpbb\datetime'); $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); } // Should fail from missing composer.json diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php index 9a0f1f512e..9a0a42fabd 100644 --- a/tests/template/template_allfolder_test.php +++ b/tests/template/template_allfolder_test.php @@ -64,7 +64,6 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case $config, $filesystem, $path_helper, - $container, $cache_path, $this->extension_manager, $loader, @@ -76,7 +75,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case ) ); $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template_path = $this->test_path . '/templates'; $this->ext_template_path = 'tests/extension/ext/vendor4/bar/styles/all/template'; diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index 54e08652a1..e245c90aee 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -158,7 +158,6 @@ Zeta test event in all', $config, $filesystem, $path_helper, - $container, $cache_path, $this->extension_manager, $loader, @@ -170,7 +169,7 @@ Zeta test event in all', ) ); $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path)); } diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index ac62e820ae..764652c9c2 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -50,7 +50,6 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te $config, $filesystem, $this->phpbb_path_helper, - $container, $cache_path, null, $loader, @@ -80,7 +79,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te ) ) ); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index cda0623dcb..e52d3b76dd 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -102,7 +102,6 @@ class phpbb_template_template_test_case extends phpbb_test_case $config, $filesystem, $path_helper, - $container, $cache_path, null, $loader, @@ -114,7 +113,7 @@ class phpbb_template_template_test_case extends phpbb_test_case ) ); $this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', $this->template_path); } diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index bf5de6b85e..ff35d16120 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -45,7 +45,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $config, $filesystem, $this->phpbb_path_helper, - $container, $cache_path, null, $loader, @@ -57,7 +56,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat ) ); $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user))); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); } } -- cgit v1.2.1 From bffd963c5033cfa49c016b7c4f163bf58d065e2b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 24 Mar 2016 10:57:23 +0100 Subject: [ticket/13616] Cleanup globals after installing the board in func tests PHPBB3-13616 --- tests/test_framework/phpbb_functional_test_case.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d234642898..829f64b780 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -384,9 +384,17 @@ class phpbb_functional_test_case extends phpbb_test_case @unlink($phpbb_root_path . 'cache/install_lock'); } - global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; + global $phpbb_container; $phpbb_container->reset(); - unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template); + + $blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader']; + + foreach (array_keys($GLOBALS) as $key) { + if (is_object($GLOBALS[$key]) && !in_array($key, $blacklist, true)) + { + unset($GLOBALS[$key]); + } + } } public function install_ext($extension) -- cgit v1.2.1 From 6d2acb5ba3fbd22b345b312e704021eab1375941 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 24 Mar 2016 13:01:52 +0100 Subject: [ticket/13616] Fix UI tests PHPBB3-13616 --- phpBB/bin/phpbbcli.php | 2 ++ phpBB/common.php | 2 ++ phpBB/includes/compatibility_globals.php | 2 -- phpBB/phpbb/install/helper/container_factory.php | 3 +++ tests/test_framework/phpbb_ui_test_case.php | 12 ++++++++++-- 5 files changed, 17 insertions(+), 4 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/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/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/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index b5ac3a576b..e79c78db29 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -256,9 +256,17 @@ class phpbb_ui_test_case extends phpbb_test_case @unlink($phpbb_root_path . 'cache/install_lock'); } - global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; + global $phpbb_container; $phpbb_container->reset(); - unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template); + + $blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader']; + + foreach (array_keys($GLOBALS) as $key) { + if (is_object($GLOBALS[$key]) && !in_array($key, $blacklist, true)) + { + unset($GLOBALS[$key]); + } + } } static protected function get_db() -- cgit v1.2.1 From 5754cbfec445919dd8b7f261de33d75cbdc78fdd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 3 Apr 2016 16:14:50 +0200 Subject: [ticket/13616] Fix CS + constant in the core extension PHPBB3-13616 --- phpBB/phpbb/di/extension/core.php | 6 ++++-- tests/test_framework/phpbb_functional_test_case.php | 3 ++- tests/test_framework/phpbb_ui_test_case.php | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 2faeff3636..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(6); + $twig_environment_options = $definition->getArgument(static::TWIG_OPTIONS_POSITION); if ($config['twig']['debug']) { $twig_environment_options['debug'] = true; @@ -82,7 +84,7 @@ class core extends Extension } // Replace the 7th argument, the options passed to the environment - $definition->replaceArgument(6, $twig_environment_options); + $definition->replaceArgument(static::TWIG_OPTIONS_POSITION, $twig_environment_options); if ($config['twig']['enable_debug_extension']) { diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 829f64b780..20b89aba4e 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -389,7 +389,8 @@ class phpbb_functional_test_case extends phpbb_test_case $blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader']; - foreach (array_keys($GLOBALS) as $key) { + foreach (array_keys($GLOBALS) as $key) + { if (is_object($GLOBALS[$key]) && !in_array($key, $blacklist, true)) { unset($GLOBALS[$key]); diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index e79c78db29..c8ca2a9003 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -261,7 +261,8 @@ class phpbb_ui_test_case extends phpbb_test_case $blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader']; - foreach (array_keys($GLOBALS) as $key) { + foreach (array_keys($GLOBALS) as $key) + { if (is_object($GLOBALS[$key]) && !in_array($key, $blacklist, true)) { unset($GLOBALS[$key]); -- cgit v1.2.1