From 3dcaa48850bf823b238391fbf9c3f085092010bc Mon Sep 17 00:00:00 2001 From: CHItA Date: Sat, 13 Jun 2015 15:35:19 +0200 Subject: [ticket/13740] Move installer files to phpbb/install directory PHPBB3-13740 --- phpBB/phpbb/install/helper/container_factory.php | 149 +++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 phpBB/phpbb/install/helper/container_factory.php (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php new file mode 100644 index 0000000000..255f8f428e --- /dev/null +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -0,0 +1,149 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\install\helper; + +use phpbb\install\exception\cannot_build_container_exception; + +class container_factory +{ + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * @var string + */ + protected $php_ext; + + /** + * @var \phpbb\request\request + */ + protected $request; + + /** + * The full phpBB container + * + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + protected $container; + + /** + * Constructor + * + * @param \phpbb\request\request $request Request interface + * @param string $phpbb_root_path Path to phpBB's root + * @param string $php_ext Extension of PHP files + */ + public function __construct(\phpbb\request\request $request, $phpbb_root_path, $php_ext) + { + $this->request = $request; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $this->container = null; + } + + /** + * Container getter + * + * @param null|string $service_name Name of the service to return + * + * @return \Symfony\Component\DependencyInjection\ContainerInterface|Object phpBB's dependency injection container + * or the service specified in $service_name + * + * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built + * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException If the service is not defined + * @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException When a circular reference is detected + * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException When the service is not defined + */ + public function get($service_name = null) + { + // Check if container was built, if not try to build it + if ($this->container === null) + { + // Check whether container can be built + // We need config.php for that so let's check if it has been set up yet + if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) + { + $this->build_container(); + } + else + { + throw new cannot_build_container_exception(); + } + } + + return ($service_name === null) ? $this->container : $this->container->get($service_name); + } + + /** + * Returns the specified parameter from the container + * + * @param string $param_name + * + * @return mixed + */ + public function get_parameter($param_name) + { + return $this->container->getParameter($param_name); + } + + /** + * Build dependency injection container + */ + protected function build_container() + { + // If the container has been already built just return. + // Although this should never happen + if ($this->container instanceof \Symfony\Component\DependencyInjection\ContainerInterface) + { + return; + } + + $phpbb_config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext); + $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); + + // For BC with functions that we need during install + global $phpbb_container; + + $disable_super_globals = $this->request->super_globals_disabled(); + + // This is needed because container_builder::get_env_parameters() uses $_SERVER + if ($disable_super_globals) + { + $this->request->enable_super_globals(); + } + + $this->container = $phpbb_container = $phpbb_container_builder + ->with_config($phpbb_config_php_file) + ->without_cache() + ->without_compiled_container() + ->get_container(); + + // Setting request is required for the compatibility globals as those are generated from + // this container + $this->container->register('request')->setSynthetic(true); + $this->container->set('request', $this->request); + $this->container->compile(); + + // Restore super globals to previous state + if ($disable_super_globals) + { + $this->request->disable_super_globals(); + } + + // Get compatibilty globals + require ($this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext); + } +} -- cgit v1.2.1 From b2b9fb1df2e6d37c8a327b7b6c380f19e1ff6496 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 21 Jul 2015 14:42:15 +0200 Subject: [ticket/13740] Fix CS and docblocks PHPBB3-13740 --- phpBB/phpbb/install/helper/container_factory.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index 255f8f428e..eb44b470b7 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -93,9 +93,26 @@ class container_factory * @param string $param_name * * @return mixed + * + * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built */ public function get_parameter($param_name) { + // Check if container was built, if not try to build it + if ($this->container === null) + { + // Check whether container can be built + // We need config.php for that so let's check if it has been set up yet + if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) + { + $this->build_container(); + } + else + { + throw new cannot_build_container_exception(); + } + } + return $this->container->getParameter($param_name); } -- cgit v1.2.1 From fbd5929606169d3f780f0a59760c171b20bd906d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 23 Jul 2015 20:50:33 +0200 Subject: [ticket/13740] Login admin when install finished PHPBB3-13740 --- phpBB/phpbb/install/helper/container_factory.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index eb44b470b7..e09e43be34 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -13,6 +13,7 @@ namespace phpbb\install\helper; +use phpbb\cache\driver\dummy; use phpbb\install\exception\cannot_build_container_exception; class container_factory @@ -152,6 +153,10 @@ class container_factory // this container $this->container->register('request')->setSynthetic(true); $this->container->set('request', $this->request); + + // Replace cache service, as config gets cached, and we don't want that + $this->container->register('cache.driver')->setSynthetic(true); + $this->container->set('cache.driver', new dummy()); $this->container->compile(); // Restore super globals to previous state -- cgit v1.2.1 From e8e9193690874e3006a7c60aaa58a22e46bce7ee Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 25 Jul 2015 14:43:54 +0200 Subject: [ticket/13740] Deduplicate container builder's checks PHPBB3-13740 --- phpBB/phpbb/install/helper/container_factory.php | 35 ++++++++++-------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index e09e43be34..dab16b81fd 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -73,16 +73,7 @@ class container_factory // Check if container was built, if not try to build it if ($this->container === null) { - // Check whether container can be built - // We need config.php for that so let's check if it has been set up yet - if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) - { - $this->build_container(); - } - else - { - throw new cannot_build_container_exception(); - } + $this->build_container(); } return ($service_name === null) ? $this->container : $this->container->get($service_name); @@ -102,16 +93,7 @@ class container_factory // Check if container was built, if not try to build it if ($this->container === null) { - // Check whether container can be built - // We need config.php for that so let's check if it has been set up yet - if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) - { - $this->build_container(); - } - else - { - throw new cannot_build_container_exception(); - } + $this->build_container(); } return $this->container->getParameter($param_name); @@ -119,6 +101,8 @@ class container_factory /** * Build dependency injection container + * + * @throws \phpbb\install\exception\cannot_build_container_exception When container cannot be built */ protected function build_container() { @@ -129,6 +113,17 @@ class container_factory return; } + // Check whether container can be built + // We need config.php for that so let's check if it has been set up yet + if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) + { + $this->build_container(); + } + else + { + throw new cannot_build_container_exception(); + } + $phpbb_config_php_file = new \phpbb\config_php_file($this->phpbb_root_path, $this->php_ext); $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); -- cgit v1.2.1 From f7641cd506bd8ad98e923ce84f9f39960a938a69 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 25 Jul 2015 15:41:10 +0200 Subject: [ticket/13740] Fix infinite config.php check loop PHPBB3-13740 --- phpBB/phpbb/install/helper/container_factory.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index dab16b81fd..dc0eef6485 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -115,11 +115,7 @@ class container_factory // Check whether container can be built // We need config.php for that so let's check if it has been set up yet - if (filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) - { - $this->build_container(); - } - else + if (!filesize($this->phpbb_root_path . 'config.' . $this->php_ext)) { throw new cannot_build_container_exception(); } -- cgit v1.2.1 From 8f5a0ad6f73e7b7757b02c827436384c96069b5a Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 09:20:50 +0200 Subject: [ticket/14039] Revamp updater PHPBB3-14039 --- phpBB/phpbb/install/helper/container_factory.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index dc0eef6485..fd42d53c00 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -134,8 +134,13 @@ class container_factory $this->request->enable_super_globals(); } - $this->container = $phpbb_container = $phpbb_container_builder + $other_config_path = $this->phpbb_root_path . 'install/update/new/config'; + $config_path = (is_dir($other_config_path)) ? $other_config_path : $this->phpbb_root_path . 'config'; + + $this->container = $phpbb_container_builder + ->with_environment('production') ->with_config($phpbb_config_php_file) + ->with_config_path($config_path) ->without_cache() ->without_compiled_container() ->get_container(); @@ -145,11 +150,17 @@ class container_factory $this->container->register('request')->setSynthetic(true); $this->container->set('request', $this->request); - // Replace cache service, as config gets cached, and we don't want that - $this->container->register('cache.driver')->setSynthetic(true); - $this->container->set('cache.driver', new dummy()); + // Replace cache service, as config gets cached, and we don't want that when we are installing + if (!is_dir($other_config_path)) + { + $this->container->register('cache.driver')->setSynthetic(true); + $this->container->set('cache.driver', new dummy()); + } + $this->container->compile(); + $phpbb_container = $this->container; + // Restore super globals to previous state if ($disable_super_globals) { -- cgit v1.2.1 From 6b561b9eae320b06178725fdccbc3e67c0990837 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 11:30:09 +0200 Subject: [ticket/14039] Use compatibility globals from the update package PHPBB3-14039 --- phpBB/phpbb/install/helper/container_factory.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index fd42d53c00..8c007de39f 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -168,6 +168,13 @@ class container_factory } // Get compatibilty globals - require ($this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext); + if (file_exists($this->phpbb_root_path . 'install/update/new/includes/compatibility_globals.' . $this->php_ext)) + { + require($this->phpbb_root_path . 'install/update/new/includes/compatibility_globals.' . $this->php_ext); + } + else + { + require($this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext); + } } } -- cgit v1.2.1 From 29908e54bcdf734150371fded932d04042580505 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 17:31:12 +0200 Subject: [ticket/14039] Use shared language service in the container factory PHPBB3-14039 --- phpBB/phpbb/install/helper/container_factory.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index 8c007de39f..efbe278628 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -15,9 +15,16 @@ namespace phpbb\install\helper; use phpbb\cache\driver\dummy; use phpbb\install\exception\cannot_build_container_exception; +use phpbb\language\language; +use phpbb\request\request; class container_factory { + /** + * @var language + */ + protected $language; + /** * @var string */ @@ -43,12 +50,14 @@ class container_factory /** * Constructor * - * @param \phpbb\request\request $request Request interface - * @param string $phpbb_root_path Path to phpBB's root - * @param string $php_ext Extension of PHP files + * @param language $language Language service + * @param request $request Request interface + * @param string $phpbb_root_path Path to phpBB's root + * @param string $php_ext Extension of PHP files */ - public function __construct(\phpbb\request\request $request, $phpbb_root_path, $php_ext) + public function __construct(language $language, request $request, $phpbb_root_path, $php_ext) { + $this->language = $language; $this->request = $request; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; @@ -150,6 +159,9 @@ class container_factory $this->container->register('request')->setSynthetic(true); $this->container->set('request', $this->request); + $this->container->register('language')->setSynthetic(true); + $this->container->set('language', $this->language); + // Replace cache service, as config gets cached, and we don't want that when we are installing if (!is_dir($other_config_path)) { -- cgit v1.2.1 From 56093d1c82d6f4d5c0f2741769eb071eb7bec5d7 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sun, 18 Oct 2015 19:18:53 +0200 Subject: [ticket/14039] Fix constants for the updater PHPBB3-14039 --- phpBB/phpbb/install/helper/container_factory.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index efbe278628..bf19efe22e 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -133,7 +133,7 @@ class container_factory $phpbb_container_builder = new \phpbb\di\container_builder($this->phpbb_root_path, $this->php_ext); // For BC with functions that we need during install - global $phpbb_container; + global $phpbb_container, $table_prefix; $disable_super_globals = $this->request->super_globals_disabled(); @@ -172,6 +172,7 @@ class container_factory $this->container->compile(); $phpbb_container = $this->container; + $table_prefix = $phpbb_config_php_file->get('table_prefix'); // Restore super globals to previous state if ($disable_super_globals) @@ -188,5 +189,15 @@ class container_factory { require($this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext); } + + // Get compatibilty globals + if (file_exists($this->phpbb_root_path . 'install/update/new/includes/constants.' . $this->php_ext)) + { + require($this->phpbb_root_path . 'install/update/new/includes/constants.' . $this->php_ext); + } + else + { + require($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); + } } } -- cgit v1.2.1 From d45f146814a1709a16fb8e4951374242d50b6aed Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 19 Oct 2015 09:12:26 +0200 Subject: [ticket/14039] Use update helper to include files in container factory PHPBB3-14039 --- phpBB/phpbb/install/helper/container_factory.php | 39 +++++++++--------------- 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index bf19efe22e..6c1ecd2d02 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -40,6 +40,11 @@ class container_factory */ protected $request; + /** + * @var update_helper + */ + protected $update_helper; + /** * The full phpBB container * @@ -50,15 +55,17 @@ class container_factory /** * Constructor * - * @param language $language Language service - * @param request $request Request interface - * @param string $phpbb_root_path Path to phpBB's root - * @param string $php_ext Extension of PHP files + * @param language $language Language service + * @param request $request Request interface + * @param update_helper $update_helper Update helper + * @param string $phpbb_root_path Path to phpBB's root + * @param string $php_ext Extension of PHP files */ - public function __construct(language $language, request $request, $phpbb_root_path, $php_ext) + public function __construct(language $language, request $request, update_helper $update_helper, $phpbb_root_path, $php_ext) { $this->language = $language; $this->request = $request; + $this->update_helper = $update_helper; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->container = null; @@ -180,24 +187,8 @@ class container_factory $this->request->disable_super_globals(); } - // Get compatibilty globals - if (file_exists($this->phpbb_root_path . 'install/update/new/includes/compatibility_globals.' . $this->php_ext)) - { - require($this->phpbb_root_path . 'install/update/new/includes/compatibility_globals.' . $this->php_ext); - } - else - { - require($this->phpbb_root_path . 'includes/compatibility_globals.' . $this->php_ext); - } - - // Get compatibilty globals - if (file_exists($this->phpbb_root_path . 'install/update/new/includes/constants.' . $this->php_ext)) - { - require($this->phpbb_root_path . 'install/update/new/includes/constants.' . $this->php_ext); - } - else - { - require($this->phpbb_root_path . 'includes/constants.' . $this->php_ext); - } + // Get compatibilty globals and constants + $this->update_helper->include_file('includes/compatibility_globals.' . $this->php_ext); + $this->update_helper->include_file('includes/constants.' . $this->php_ext); } } -- cgit v1.2.1 From 955b9ede33c5696173a760ea271ec32d79e843b9 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 11 Feb 2016 13:18:30 +0100 Subject: [ticket/14462] Further speed improvements - Cache the secondary container - Only initialize tasks/modules that are being used - Add timeout error message in the AJAX UI PHPBB3-14462 --- phpBB/phpbb/install/helper/container_factory.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'phpBB/phpbb/install/helper/container_factory.php') diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index 6c1ecd2d02..5cf4f8a283 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -13,7 +13,6 @@ namespace phpbb\install\helper; -use phpbb\cache\driver\dummy; use phpbb\install\exception\cannot_build_container_exception; use phpbb\language\language; use phpbb\request\request; @@ -157,25 +156,20 @@ class container_factory ->with_environment('production') ->with_config($phpbb_config_php_file) ->with_config_path($config_path) - ->without_cache() ->without_compiled_container() ->get_container(); // Setting request is required for the compatibility globals as those are generated from // this container - $this->container->register('request')->setSynthetic(true); - $this->container->set('request', $this->request); - - $this->container->register('language')->setSynthetic(true); - $this->container->set('language', $this->language); - - // Replace cache service, as config gets cached, and we don't want that when we are installing - if (!is_dir($other_config_path)) + if (!$this->container->isFrozen()) { - $this->container->register('cache.driver')->setSynthetic(true); - $this->container->set('cache.driver', new dummy()); + $this->container->register('request')->setSynthetic(true); + $this->container->register('language')->setSynthetic(true); } + $this->container->set('request', $this->request); + $this->container->set('language', $this->language); + $this->container->compile(); $phpbb_container = $this->container; -- 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/phpbb/install/helper/container_factory.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/phpbb/install/helper/container_factory.php') 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); } } -- cgit v1.2.1