From 8e2cbe39cdd7672638dbc0d6a0f65a7365db0d91 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 04:06:52 +0200 Subject: [feature/dic] Convert common.php to Symfony2 DependencyInjection component PHPBB3-10739 --- phpBB/common.php | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index b3b8d7e4f7..aa6115fe1c 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -15,6 +15,9 @@ if (!defined('IN_PHPBB')) exit; } +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\EventDispatcher\EventDispatcher; require($phpbb_root_path . 'includes/startup.' . $phpEx); @@ -91,43 +94,41 @@ $phpbb_class_loader_ext->register(); $phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); $phpbb_class_loader->register(); +$container = new ContainerBuilder(); +$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/config')); +$loader->load('parameters.yml'); +$loader->load('services.yml'); + +$container->setParameter('core.root_path', $phpbb_root_path); +$container->setParameter('core.php_ext', $phpEx); + // set up caching -$cache_factory = new phpbb_cache_factory($acm_type); -$cache = $cache_factory->get_service(); +$cache = $container->get('cache'); $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes -$phpbb_dispatcher = new phpbb_event_dispatcher(); -$request = new phpbb_request(); -$user = new phpbb_user(); -$auth = new phpbb_auth(); -$db = new $sql_db(); +$phpbb_dispatcher = $container->get('dispatcher'); +$request = $container->get('request'); +$user = $container->get('user'); +$auth = $container->get('auth'); +$db = $container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function -// Connect to DB -$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false); - -// We do not need this any longer, unset for safety purposes -unset($dbpasswd); - // Grab global variables, re-cache if necessary -$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); +$config = $container->get('config'); set_config(null, null, null, $config); set_config_count(null, null, null, $config); // load extensions -$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); +$phpbb_extension_manager = $container->get('ext.manager'); -// Initialize style -$phpbb_style_resource_locator = new phpbb_style_resource_locator(); -$phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); -$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider); -$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); +$template = $container->get('template'); +$style = $container->get('style'); -$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); +$phpbb_subscriber_loader = $container->get('event.subscriber_loader'); $phpbb_subscriber_loader->load(); // Add own hook handler -- cgit v1.2.1 From 776160a7e35a1f82325b7acf573906310791c573 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 20:23:33 +0200 Subject: [feature/dic] Fetch cache driver explicitly PHPBB3-10739 --- phpBB/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index aa6115fe1c..591969df74 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -104,8 +104,8 @@ $container->setParameter('core.php_ext', $phpEx); // set up caching $cache = $container->get('cache'); -$phpbb_class_loader_ext->set_cache($cache->get_driver()); -$phpbb_class_loader->set_cache($cache->get_driver()); +$phpbb_class_loader_ext->set_cache($container->get('cache.driver')); +$phpbb_class_loader->set_cache($container->get('cache.driver')); // Instantiate some basic classes $phpbb_dispatcher = $container->get('dispatcher'); -- cgit v1.2.1 From bca600877cbd92246949366238d365bbc3039d5a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 20:27:46 +0200 Subject: [feature/dic] Move cron manager into DIC PHPBB3-10739 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 591969df74..0446b5c15e 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -142,5 +142,5 @@ foreach ($cache->obtain_hooks() as $hook) if (!$config['use_system_cron']) { - $cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver()); + $cron = $container->get('cron.manager'); } -- cgit v1.2.1 From 873630f04e6502cc69e6b208f596414f240bc923 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 20:45:33 +0200 Subject: [feature/dic] Move class loader into DIC PHPBB3-10739 --- phpBB/common.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 0446b5c15e..117dc2051e 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -88,12 +88,6 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -// Setup class loader first -$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); -$phpbb_class_loader_ext->register(); -$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); -$phpbb_class_loader->register(); - $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/config')); $loader->load('parameters.yml'); @@ -102,6 +96,12 @@ $loader->load('services.yml'); $container->setParameter('core.root_path', $phpbb_root_path); $container->setParameter('core.php_ext', $phpEx); +// Setup class loader first +$phpbb_class_loader_ext = $container->get('class_loader.ext'); +$phpbb_class_loader_ext->register(); +$phpbb_class_loader = $container->get('class_loader'); +$phpbb_class_loader->register(); + // set up caching $cache = $container->get('cache'); $phpbb_class_loader_ext->set_cache($container->get('cache.driver')); @@ -124,13 +124,12 @@ set_config_count(null, null, null, $config); // load extensions $phpbb_extension_manager = $container->get('ext.manager'); +$phpbb_subscriber_loader = $container->get('event.subscriber_loader'); +$phpbb_subscriber_loader->load(); $template = $container->get('template'); $style = $container->get('style'); -$phpbb_subscriber_loader = $container->get('event.subscriber_loader'); -$phpbb_subscriber_loader->load(); - // 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'))); -- cgit v1.2.1 From dc9ccc432cd0b24cf762f8285d8a90f52b8efe5b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 21:20:58 +0200 Subject: [feature/dic] Make use of calls to cut down on boilerplate PHPBB3-10739 --- phpBB/common.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 117dc2051e..51478662d7 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -97,15 +97,11 @@ $container->setParameter('core.root_path', $phpbb_root_path); $container->setParameter('core.php_ext', $phpEx); // Setup class loader first -$phpbb_class_loader_ext = $container->get('class_loader.ext'); -$phpbb_class_loader_ext->register(); $phpbb_class_loader = $container->get('class_loader'); -$phpbb_class_loader->register(); +$phpbb_class_loader_ext = $container->get('class_loader.ext'); // set up caching $cache = $container->get('cache'); -$phpbb_class_loader_ext->set_cache($container->get('cache.driver')); -$phpbb_class_loader->set_cache($container->get('cache.driver')); // Instantiate some basic classes $phpbb_dispatcher = $container->get('dispatcher'); @@ -125,7 +121,6 @@ set_config_count(null, null, null, $config); // load extensions $phpbb_extension_manager = $container->get('ext.manager'); $phpbb_subscriber_loader = $container->get('event.subscriber_loader'); -$phpbb_subscriber_loader->load(); $template = $container->get('template'); $style = $container->get('style'); -- cgit v1.2.1 From 2e76620c8824da62f97cfdaee8f9b1014159fd7c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 9 Apr 2012 00:22:55 +0200 Subject: [feature/dic] Rewrite cron system to use DIC PHPBB3-10739 --- phpBB/common.php | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 51478662d7..c9eb5d217b 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -88,42 +88,43 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -$container = new ContainerBuilder(); -$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/config')); +$phpbb_container = new ContainerBuilder(); +$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/config')); $loader->load('parameters.yml'); $loader->load('services.yml'); -$container->setParameter('core.root_path', $phpbb_root_path); -$container->setParameter('core.php_ext', $phpEx); +$phpbb_container->setParameter('core.root_path', $phpbb_root_path); +$phpbb_container->setParameter('core.php_ext', $phpEx); +$phpbb_container->set('container', $phpbb_container); // Setup class loader first -$phpbb_class_loader = $container->get('class_loader'); -$phpbb_class_loader_ext = $container->get('class_loader.ext'); +$phpbb_class_loader = $phpbb_container->get('class_loader'); +$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); // set up caching -$cache = $container->get('cache'); +$cache = $phpbb_container->get('cache'); // Instantiate some basic classes -$phpbb_dispatcher = $container->get('dispatcher'); -$request = $container->get('request'); -$user = $container->get('user'); -$auth = $container->get('auth'); -$db = $container->get('dbal.conn'); +$phpbb_dispatcher = $phpbb_container->get('dispatcher'); +$request = $phpbb_container->get('request'); +$user = $phpbb_container->get('user'); +$auth = $phpbb_container->get('auth'); +$db = $phpbb_container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function // Grab global variables, re-cache if necessary -$config = $container->get('config'); +$config = $phpbb_container->get('config'); set_config(null, null, null, $config); set_config_count(null, null, null, $config); // load extensions -$phpbb_extension_manager = $container->get('ext.manager'); -$phpbb_subscriber_loader = $container->get('event.subscriber_loader'); +$phpbb_extension_manager = $phpbb_container->get('ext.manager'); +$phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); -$template = $container->get('template'); -$style = $container->get('style'); +$template = $phpbb_container->get('template'); +$style = $phpbb_container->get('style'); // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); @@ -136,5 +137,5 @@ foreach ($cache->obtain_hooks() as $hook) if (!$config['use_system_cron']) { - $cron = $container->get('cron.manager'); + $cron = $phpbb_container->get('cron.manager'); } -- cgit v1.2.1 From 32d2ee61f78e3aeaac5f4f1bcb672c67aa10b10e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 16:14:21 +0200 Subject: [feature/dic] Configure container via config.php, use compiler pass PHPBB3-10739 --- phpBB/common.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index a69b26c006..e7dabec4ca 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -8,6 +8,11 @@ * Minimum Requirement: PHP 5.3.2 */ +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\Compiler\Compiler; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + /** */ if (!defined('IN_PHPBB')) @@ -15,11 +20,6 @@ if (!defined('IN_PHPBB')) exit; } -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\EventDispatcher\EventDispatcher; - require($phpbb_root_path . 'includes/startup.' . $phpEx); if (file_exists($phpbb_root_path . 'config.' . $phpEx)) @@ -77,25 +77,26 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +require($phpbb_root_path . 'includes/di/compiler/config_pass.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); +require($phpbb_root_path . 'includes/db/' . ltrim($dbms, 'dbal_') . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); + // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); $phpbb_container = new ContainerBuilder(); $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/config')); -$loader->load('parameters.yml'); $loader->load('services.yml'); -$phpbb_container->setParameter('core.root_path', $phpbb_root_path); -$phpbb_container->setParameter('core.php_ext', $phpEx); -$phpbb_container->set('container', $phpbb_container); +$phpbb_compiler = new Compiler(); +$phpbb_compiler->addPass(new phpbb_di_compiler_config_pass($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx)); +$phpbb_compiler->compile($phpbb_container); // Setup class loader first $phpbb_class_loader = $phpbb_container->get('class_loader'); -- cgit v1.2.1 From 967cc550ed9bb74480f46212768502627f26d62d Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 20:42:07 +0200 Subject: [feature/dic] Introduce DI processors instead of abusing compiler passes PHPBB3-10739 --- phpBB/common.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index e7dabec4ca..406d8bb093 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -77,7 +77,8 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/di/compiler/config_pass.' . $phpEx); +require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); +require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); @@ -94,9 +95,8 @@ $phpbb_container = new ContainerBuilder(); $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/config')); $loader->load('services.yml'); -$phpbb_compiler = new Compiler(); -$phpbb_compiler->addPass(new phpbb_di_compiler_config_pass($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx)); -$phpbb_compiler->compile($phpbb_container); +$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); +$processor->process($phpbb_container); // Setup class loader first $phpbb_class_loader = $phpbb_container->get('class_loader'); -- cgit v1.2.1 From 50bc453aa6c91ae9c9df5cb633615825c9df7b6d Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 21:02:55 +0200 Subject: [feature/dic] Load services from extensions PHPBB3-10739 --- phpBB/common.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 406d8bb093..f958f06ce0 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -9,7 +9,6 @@ */ use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\Compiler\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; @@ -102,6 +101,12 @@ $processor->process($phpbb_container); $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); +$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); +foreach ($ids as $id) { + $processor = $phpbb_container->get($id); + $processor->process($phpbb_container); +} + // set up caching $cache = $phpbb_container->get('cache'); -- cgit v1.2.1 From 4feb9aa8d7bda303b62acec924008f75042eb757 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 25 Aug 2012 16:43:41 +0200 Subject: [feature/dic] Coding style: Braces PHPBB3-10739 --- phpBB/common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index f958f06ce0..02dad17cf0 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -102,7 +102,8 @@ $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); $ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); -foreach ($ids as $id) { +foreach ($ids as $id) +{ $processor = $phpbb_container->get($id); $processor->process($phpbb_container); } -- cgit v1.2.1 From 7ed7b19a1f1c3732b561ec3c8a4a39f115b5e6ac Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 1 Sep 2012 19:12:57 +0200 Subject: [feature/dic] Remove unneeded newline PHPBB3-10739 --- phpBB/common.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 6ca495a7e3..281eb88c4d 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -86,7 +86,6 @@ require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/db/' . ltrim($dbms, 'dbal_') . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); - // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -- cgit v1.2.1 From d543f0ffb1334d0a22c30077a9ed27c098dc4af5 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 8 Sep 2012 14:41:41 +0200 Subject: [ticket/11101] Delay execution of container processors Also fix the name of the ext processor service. PHPBB3-11101 --- phpBB/common.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 281eb88c4d..c6bb5c6cfe 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -100,13 +100,6 @@ $processor->process($phpbb_container); $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); -$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); -foreach ($ids as $id) -{ - $processor = $phpbb_container->get($id); - $processor->process($phpbb_container); -} - // set up caching $cache = $phpbb_container->get('cache'); @@ -132,6 +125,13 @@ $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); $template = $phpbb_container->get('template'); $phpbb_style = $phpbb_container->get('style'); +$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); +foreach ($ids as $id) +{ + $processor = $phpbb_container->get($id); + $processor->process($phpbb_container); +} + // 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('phpbb_template', 'display'))); -- cgit v1.2.1 From c630480ca1a426cb0897be35626baac2694fccf5 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 17 Oct 2012 15:03:06 -0400 Subject: [ticket/10848] Redirect from adm to installer correctly. PHPBB3-10848 --- phpBB/common.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 491addc5e0..bdb33707cc 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -38,10 +38,14 @@ if (!defined('PHPBB_INSTALLED')) $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); } + // $phpbb_root_path accounts for redirects from e.g. /adm + $script_path = trim(dirname($script_name)) . '/' . $phpbb_root_path . 'install/index.' . $phpEx; // Replace any number of consecutive backslashes and/or slashes with a single slash // (could happen on some proxy setups and/or Windows servers) - $script_path = trim(dirname($script_name)) . '/install/index.' . $phpEx; $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path); + // Eliminate . and .. from the path + require($phpbb_root_path . 'includes/functions.' . $phpEx); + $script_path = clean_path($script_path); $url = (($secure) ? 'https://' : 'http://') . $server_name; -- cgit v1.2.1 From bb09cd9c8e76ac3af848d09db8ea1928dab66158 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 17 Oct 2012 15:13:35 -0400 Subject: [ticket/10848] Add phpbb_ prefix. PHPBB3-10848 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index bdb33707cc..5849d48453 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -45,7 +45,7 @@ if (!defined('PHPBB_INSTALLED')) $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path); // Eliminate . and .. from the path require($phpbb_root_path . 'includes/functions.' . $phpEx); - $script_path = clean_path($script_path); + $script_path = phpbb_clean_path($script_path); $url = (($secure) ? 'https://' : 'http://') . $server_name; -- cgit v1.2.1 From b283df8241c3d8fc5f2684e37d8a0f237df39c4f Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 17 Oct 2012 22:35:36 -0400 Subject: [ticket/10848] Move include up. PHPBB3-10848 --- phpBB/common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 5849d48453..31ca746924 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -26,6 +26,8 @@ if (file_exists($phpbb_root_path . 'config.' . $phpEx)) if (!defined('PHPBB_INSTALLED')) { // Redirect the user to the installer + require($phpbb_root_path . 'includes/functions.' . $phpEx); + // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information // available as used by the redirect function $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); @@ -44,7 +46,6 @@ if (!defined('PHPBB_INSTALLED')) // (could happen on some proxy setups and/or Windows servers) $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path); // Eliminate . and .. from the path - require($phpbb_root_path . 'includes/functions.' . $phpEx); $script_path = phpbb_clean_path($script_path); $url = (($secure) ? 'https://' : 'http://') . $server_name; -- cgit v1.2.1 From 7d7dc98b10b586635fdee5c420e1ae9fa8d2b752 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 9 Nov 2012 23:16:42 +0100 Subject: [ticket/11181] Bump PHP requirement to 5.3.3 (from 5.3.2) PHPBB3-11181 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 6943b02fa0..c9e3039e1f 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -5,7 +5,7 @@ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * -* Minimum Requirement: PHP 5.3.2 +* Minimum Requirement: PHP 5.3.3 */ use Symfony\Component\Config\FileLocator; -- cgit v1.2.1 From 195014867ae84fe04ec01c913e38bf1d435590f7 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 11:25:22 +0100 Subject: [ticket/11183] Remove $load_extensions and weird dl() calls PHPBB3-11183 --- phpBB/common.php | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 6943b02fa0..6817b63d7b 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -67,18 +67,6 @@ if (!defined('PHPBB_INSTALLED')) exit; } -// Load Extensions -// dl() is deprecated and disabled by default as of PHP 5.3. -if (!empty($load_extensions) && function_exists('dl')) -{ - $load_extensions = explode(',', $load_extensions); - - foreach ($load_extensions as $extension) - { - @dl(trim($extension)); - } -} - // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); -- cgit v1.2.1 From f48709f5bb8fb1b916d308e3b4bb06bc96d08611 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 19 Oct 2012 19:53:29 -0400 Subject: [feature/compiled-dic] Compile the DI Container into a cached class PHPBB3-11152 --- phpBB/common.php | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 6943b02fa0..a681561619 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -81,8 +81,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); -require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); @@ -94,16 +92,28 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -$phpbb_container = new ContainerBuilder(); -$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/config')); -$loader->load('services.yml'); - -$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); -$processor->process($phpbb_container); - // Setup class loader first -$phpbb_class_loader = $phpbb_container->get('class_loader'); -$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); +$phpbb_class_loader->register(); +$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx"); +$phpbb_class_loader_ext->register(); + +// Set up container +$phpbb_container = phpbb_create_compiled_container( + array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), + ), + array( + new phpbb_event_kernel_compiler_pass(), + ), + $phpbb_root_path . 'config.' . $phpEx, + $phpbb_root_path, + $phpEx +); + +$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); +$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); // set up caching $cache = $phpbb_container->get('cache'); @@ -130,13 +140,6 @@ $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); $template = $phpbb_container->get('template'); $phpbb_style = $phpbb_container->get('style'); -$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); -foreach ($ids as $id) -{ - $processor = $phpbb_container->get($id); - $processor->process($phpbb_container); -} - // 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('phpbb_template', 'display'))); -- cgit v1.2.1 From b20d852b7fc43431ade40ee97fd5ece5e3271d5d Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 20 Oct 2012 16:57:21 -0400 Subject: [feature/compiled-dic] Remove HttpKernel-related stuff These things should be added in the Controller PR instead. PHPBB3-11152 --- phpBB/common.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index a681561619..fce08f3834 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -104,9 +104,7 @@ $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( - new phpbb_event_kernel_compiler_pass(), - ), + array(), $phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx -- cgit v1.2.1 From cb2725dd5a04118de8628e10f940e926f4fa8fa1 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 21 Oct 2012 16:09:43 -0400 Subject: [feature/compiled-dic] Fix cron task loading We cannot use container tags at run time if we are using a cached, compiled container object (i.e. phpbb_cache_container) so we have to load them beforehand. PHPBB3-11152 --- phpBB/common.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index fce08f3834..6a7def1884 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -104,8 +104,9 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array(), - $phpbb_root_path . 'config.' . $phpEx, + array( + new phpbb_di_pass_cron(), + ), $phpbb_root_path, $phpEx ); -- cgit v1.2.1 From 897e8f2e8361839a92acae7e77225ef212e44647 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 9 Nov 2012 23:00:44 +0100 Subject: [ticket/11152] Move container functions to a separate function file PHPBB3-11152 --- phpBB/common.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 6a7def1884..e24f9b4359 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -84,6 +84,7 @@ require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); +require($phpbb_root_path . 'includes/functions_container.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/db/' . ltrim($dbms, 'dbal_') . '.' . $phpEx); -- cgit v1.2.1 From 231d743ba9966e8304e0dd226ebf5eb7fb3b70d8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 23:34:27 +0100 Subject: [ticket/11152] Change phpbb_di_pass_cron to generic phpbb_di_pass_collection PHPBB3-11152 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index e24f9b4359..fb2f86341b 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -106,7 +106,7 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_cron(), + new phpbb_di_pass_collection('cron.task_collection', 'cron.task'), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 8851b797fbf0f1b4120aa4d3ae713711e01ef98f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 23:35:52 +0100 Subject: [ticket/11152] Create separate function for debug-dependent container PHPBB3-11152 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index fb2f86341b..b435970692 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -100,7 +100,7 @@ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_pat $phpbb_class_loader_ext->register(); // Set up container -$phpbb_container = phpbb_create_compiled_container( +$phpbb_container = phpbb_create_dumped_container_unless_debug( array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), -- cgit v1.2.1 From 3e4d3761fdec878758e43779eab124816596c8aa Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 11 Nov 2012 14:18:11 +0100 Subject: [ticket/11152] Rename collection to collection_pass PHPBB3-11152 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index b435970692..6dc018c5c2 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -106,7 +106,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_collection('cron.task_collection', 'cron.task'), + new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From d2a051cdd4269fd5749bdd4e7619fc5176a510a8 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 11 Nov 2012 18:39:24 +0100 Subject: [ticket/11193] Instantiate a single collection_pass for all collections PHPBB3-11193 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 002d435b6e..c4237dfcf5 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -94,7 +94,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'), + new phpbb_di_pass_collection_pass(), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 06158693c7b846518abfe9d72491fc7376e457f3 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 19 Oct 2012 19:54:19 -0400 Subject: [feature/controller] Implement a front controller PHPBB3-10864 --- phpBB/common.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index c4237dfcf5..986f0a8839 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -8,9 +8,7 @@ * Minimum Requirement: PHP 5.3.3 */ -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\HttpFoundation\Request; /** */ @@ -106,6 +104,11 @@ $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); // set up caching $cache = $phpbb_container->get('cache'); +// Instantiate the Symfony Request object +// This must be done before phpbb_request +// because otherwise globals are disabled +$symfony_request = Request::createFromGlobals(); + // Instantiate some basic classes $phpbb_dispatcher = $phpbb_container->get('dispatcher'); $request = $phpbb_container->get('request'); -- cgit v1.2.1 From 97957d679250c642969a09b002f4125889a5f4fa Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 21 Oct 2012 16:37:03 -0400 Subject: [feature/controller-new] Rename kernel compiler pass class PHPBB3-10864 --- phpBB/common.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index 986f0a8839..b0bc281b45 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -93,6 +93,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( ), array( new phpbb_di_pass_collection_pass(), + new phpbb_di_pass_kernel(), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 4b6d538b062a56f55ba221ac8437b4bfc712a475 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 13 Nov 2012 09:28:56 -0500 Subject: [feature/controller] Rename kernel pass class properly PHPBB3-10864 --- phpBB/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index b0bc281b45..a5ffcea8e4 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -93,7 +93,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( ), array( new phpbb_di_pass_collection_pass(), - new phpbb_di_pass_kernel(), + new phpbb_di_pass_kernel_pass(), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 8913b2c7c4ffc38d4caf34ca7014b8a07f11d19d Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 17 Nov 2012 17:48:20 -0500 Subject: [feature/controller] Use query string, not path info, for controller access This is hopefully just temporary until we can fix the relative path issue. PHPBB3-10864 --- phpBB/common.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'phpBB/common.php') diff --git a/phpBB/common.php b/phpBB/common.php index a5ffcea8e4..e99b9edee5 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -8,8 +8,6 @@ * Minimum Requirement: PHP 5.3.3 */ -use Symfony\Component\HttpFoundation\Request; - /** */ if (!defined('IN_PHPBB')) @@ -105,11 +103,6 @@ $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); // set up caching $cache = $phpbb_container->get('cache'); -// Instantiate the Symfony Request object -// This must be done before phpbb_request -// because otherwise globals are disabled -$symfony_request = Request::createFromGlobals(); - // Instantiate some basic classes $phpbb_dispatcher = $phpbb_container->get('dispatcher'); $request = $phpbb_container->get('request'); -- cgit v1.2.1