From e7804ecce4511d8befdcc28f6705c3589c47c878 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 27 Jun 2014 21:02:20 +0200 Subject: [ticket/12775] Update phpBB/install/database_update.php PHPBB3-12775 --- phpBB/includes/functions_container.php | 586 ++++++++++++++++----------------- 1 file changed, 290 insertions(+), 296 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index a00613c26b..96086a59ed 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -1,297 +1,291 @@ -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; - -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -/** -* Get DB connection from config.php. -* -* Used to bootstrap the container. -* -* @param string $config_file -* @return \phpbb\db\driver\driver_interface -*/ -function phpbb_bootstrap_db_connection($config_file) -{ - require($config_file); - $dbal_driver_class = phpbb_convert_30_dbms_to_31($dbms); - - $db = new $dbal_driver_class(); - $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, defined('PHPBB_DB_NEW_LINK')); - - return $db; -} - -/** -* Get table prefix from config.php. -* -* Used to bootstrap the container. -* -* @param string $config_file -* @return string table prefix -*/ -function phpbb_bootstrap_table_prefix($config_file) -{ - require($config_file); - return $table_prefix; -} - -/** -* Get enabled extensions. -* -* Used to bootstrap the container. -* -* @param string $config_file -* @param string $phpbb_root_path -* @param \phpbb\db\driver\driver_interface $db The generated connection -* @return array enabled extensions -*/ -function phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path, &$db) -{ - $db = phpbb_bootstrap_db_connection($config_file); - $table_prefix = phpbb_bootstrap_table_prefix($config_file); - $extension_table = $table_prefix.'ext'; - - $sql = 'SELECT * - FROM ' . $extension_table . ' - WHERE ext_active = 1'; - - $result = $db->sql_query($sql); - $rows = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - $exts = array(); - foreach ($rows as $row) - { - $exts[$row['ext_name']] = $phpbb_root_path . 'ext/' . $row['ext_name'] . '/'; - } - - return $exts; -} - -/** -* Create the ContainerBuilder object -* -* @param array $extensions Array of Container extension objects -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object -*/ -function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext) -{ - $container = new ContainerBuilder(); - - foreach ($extensions as $extension) - { - $container->registerExtension($extension); - $container->loadFromExtension($extension->getAlias()); - } - - $container->setParameter('core.root_path', $phpbb_root_path); - $container->setParameter('core.php_ext', $php_ext); - - return $container; -} - -/** -* Create installer container -* -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object -*/ -function phpbb_create_install_container($phpbb_root_path, $php_ext) -{ - $other_config_path = $phpbb_root_path . 'install/update/new/config/'; - $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; - - $core = new \phpbb\di\extension\core($config_path); - $container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext); - - $container->setParameter('core.root_path', $phpbb_root_path); - $container->setParameter('core.adm_relative_path', $phpbb_adm_relative_path); - $container->setParameter('core.php_ext', $php_ext); - $container->setParameter('core.table_prefix', ''); - - $container->register('dbal.conn.driver')->setSynthetic(true); - - $container->setAlias('cache.driver', 'cache.driver.install'); - - $container->compile(); - - return $container; -} - -/** -* Create updater container -* -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @param array $config_path Path to config directory -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_update_container($phpbb_root_path, $php_ext, $config_path) -{ - $config_file = $phpbb_root_path . 'config.' . $php_ext; - return phpbb_create_compiled_container( - $config_file, - array( - new phpbb\di\extension\config($config_file), - new phpbb\di\extension\core($config_path), - ), - array( - new phpbb\di\pass\collection_pass(), - new phpbb\di\pass\kernel_pass(), - ), - $phpbb_root_path, - $php_ext - ); -} - -/** -* Create a compiled ContainerBuilder object -* -* @param array $extensions Array of Container extension objects -* @param array $passes Array of Compiler Pass objects -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_compiled_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) -{ - // Create the final container to be compiled and cached - $container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext); - - // Compile the container - foreach ($passes as $pass) - { - $container->addCompilerPass($pass); - } - $container->compile(); - - return $container; -} - -/** -* Create a compiled and dumped ContainerBuilder object -* -* @param array $extensions Array of Container extension objects -* @param array $passes Array of Compiler Pass objects -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_dumped_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) -{ - // Check for our cached container; if it exists, use it - $container_filename = phpbb_container_filename($phpbb_root_path, $php_ext); - if (file_exists($container_filename)) - { - require($container_filename); - return new phpbb_cache_container(); - } - - $container = phpbb_create_compiled_container($config_file, $extensions, $passes, $phpbb_root_path, $php_ext); - - // Lastly, we create our cached container class - $dumper = new PhpDumper($container); - $cached_container_dump = $dumper->dump(array( - 'class' => 'phpbb_cache_container', - 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', - )); - - file_put_contents($container_filename, $cached_container_dump); - - return $container; -} - -/** -* Create an environment-specific ContainerBuilder object -* -* If debug is enabled, the container is re-compiled every time. -* This ensures that the latest changes will always be reflected -* during development. -* -* Otherwise it will get the existing dumped container and use -* that one instead. -* -* @param array $extensions Array of Container extension objects -* @param array $passes Array of Compiler Pass objects -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_dumped_container_unless_debug($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) -{ - $container_factory = defined('DEBUG_CONTAINER') ? 'phpbb_create_compiled_container' : 'phpbb_create_dumped_container'; - return $container_factory($config_file, $extensions, $passes, $phpbb_root_path, $php_ext); -} - -/** -* Create a default ContainerBuilder object -* -* Contains the default configuration of the phpBB container. -* -* @param array $extensions Array of Container extension objects -* @param array $passes Array of Compiler Pass objects -* @return ContainerBuilder object (compiled) -*/ -function phpbb_create_default_container($phpbb_root_path, $php_ext) -{ - $config_file = $phpbb_root_path . 'config.' . $php_ext; - $db = null; - $installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path, $db); - - $container = phpbb_create_dumped_container_unless_debug( - $config_file, - array( - new \phpbb\di\extension\config($config_file), - new \phpbb\di\extension\core($phpbb_root_path . 'config'), - new \phpbb\di\extension\ext($installed_exts), - ), - array( - new \phpbb\di\pass\collection_pass(), - new \phpbb\di\pass\kernel_pass(), - ), - $phpbb_root_path, - $php_ext - ); - - $container->get('dbal.conn')->set_driver($db); - - return $container; -} - -/** -* Get the filename under which the dumped container will be stored. -* -* @param string $phpbb_root_path Root path -* @param string $php_ext PHP Extension -* @return Path for dumped container -*/ -function phpbb_container_filename($phpbb_root_path, $php_ext) -{ - $filename = str_replace(array('/', '.'), array('slash', 'dot'), $phpbb_root_path); - return $phpbb_root_path . 'cache/container_' . $filename . '.' . $php_ext; -} +///** +//* +//* This file is part of the phpBB Forum Software package. +//* +//* @copyright (c) phpBB Limited +//* @license GNU General Public License, version 2 (GPL-2.0) +//* +//* For full copyright and license information, please see +//* the docs/CREDITS.txt file. +//* +//*/ +// +//use Symfony\Component\Config\FileLocator; +//use Symfony\Component\DependencyInjection\ContainerBuilder; +//use Symfony\Component\DependencyInjection\Dumper\PhpDumper; +//use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +// +///** +//* @ignore +//*/ +//if (!defined('IN_PHPBB')) +//{ +// exit; +//} +// +///** +//* Get DB connection from config.php. +//* +//* Used to bootstrap the container. +//* +//* @param string $config_file +//* @return \phpbb\db\driver\driver_interface +//*/ +//function phpbb_bootstrap_db_connection($config_file) +//{ +// require($config_file); +// $dbal_driver_class = phpbb_convert_30_dbms_to_31($dbms); +// +// $db = new $dbal_driver_class(); +// $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, defined('PHPBB_DB_NEW_LINK')); +// +// return $db; +//} +// +///** +//* Get table prefix from config.php. +//* +//* Used to bootstrap the container. +//* +//* @param string $config_file +//* @return string table prefix +//*/ +//function phpbb_bootstrap_table_prefix($config_file) +//{ +// require($config_file); +// return $table_prefix; +//} +// +///** +//* Get enabled extensions. +//* +//* Used to bootstrap the container. +//* +//* @param string $config_file +//* @param string $phpbb_root_path +//* @return array enabled extensions +//*/ +//function phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path) +//{ +// $db = phpbb_bootstrap_db_connection($config_file); +// $table_prefix = phpbb_bootstrap_table_prefix($config_file); +// $extension_table = $table_prefix.'ext'; +// +// $sql = 'SELECT * +// FROM ' . $extension_table . ' +// WHERE ext_active = 1'; +// +// $result = $db->sql_query($sql); +// $rows = $db->sql_fetchrowset($result); +// $db->sql_freeresult($result); +// +// $exts = array(); +// foreach ($rows as $row) +// { +// $exts[$row['ext_name']] = $phpbb_root_path . 'ext/' . $row['ext_name'] . '/'; +// } +// +// return $exts; +//} +// +///** +//* Create the ContainerBuilder object +//* +//* @param array $extensions Array of Container extension objects +//* @param string $phpbb_root_path Root path +//* @param string $php_ext PHP Extension +//* @return ContainerBuilder object +//*/ +//function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext) +//{ +// $container = new ContainerBuilder(); +// +// foreach ($extensions as $extension) +// { +// $container->registerExtension($extension); +// $container->loadFromExtension($extension->getAlias()); +// } +// +// $container->setParameter('core.root_path', $phpbb_root_path); +// $container->setParameter('core.php_ext', $php_ext); +// +// return $container; +//} +// +///** +//* Create installer container +//* +//* @param string $phpbb_root_path Root path +//* @param string $php_ext PHP Extension +//* @return ContainerBuilder object +//*/ +//function phpbb_create_install_container($phpbb_root_path, $php_ext) +//{ +// $other_config_path = $phpbb_root_path . 'install/update/new/config/'; +// $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; +// +// $core = new \phpbb\di\extension\core($config_path); +// $container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext); +// +// $container->setParameter('core.root_path', $phpbb_root_path); +// $container->setParameter('core.adm_relative_path', $phpbb_adm_relative_path); +// $container->setParameter('core.php_ext', $php_ext); +// $container->setParameter('core.table_prefix', ''); +// +// $container->register('dbal.conn')->setSynthetic(true); +// +// $container->setAlias('cache.driver', 'cache.driver.install'); +// +// $container->compile(); +// +// return $container; +//} +// +///** +//* Create updater container +//* +//* @param string $phpbb_root_path Root path +//* @param string $php_ext PHP Extension +//* @param array $config_path Path to config directory +//* @return ContainerBuilder object (compiled) +//*/ +//function phpbb_create_update_container($phpbb_root_path, $php_ext, $config_path) +//{ +// $config_file = $phpbb_root_path . 'config.' . $php_ext; +// return phpbb_create_compiled_container( +// $config_file, +// array( +// new phpbb\di\extension\config($config_file), +// new phpbb\di\extension\core($config_path), +// ), +// array( +// new phpbb\di\pass\collection_pass(), +// new phpbb\di\pass\kernel_pass(), +// ), +// $phpbb_root_path, +// $php_ext +// ); +//} +// +///** +//* Create a compiled ContainerBuilder object +//* +//* @param array $extensions Array of Container extension objects +//* @param array $passes Array of Compiler Pass objects +//* @param string $phpbb_root_path Root path +//* @param string $php_ext PHP Extension +//* @return ContainerBuilder object (compiled) +//*/ +//function phpbb_create_compiled_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) +//{ +// // Create the final container to be compiled and cached +// $container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext); +// +// // Compile the container +// foreach ($passes as $pass) +// { +// $container->addCompilerPass($pass); +// } +// $container->compile(); +// +// return $container; +//} +// +///** +//* Create a compiled and dumped ContainerBuilder object +//* +//* @param array $extensions Array of Container extension objects +//* @param array $passes Array of Compiler Pass objects +//* @param string $phpbb_root_path Root path +//* @param string $php_ext PHP Extension +//* @return ContainerBuilder object (compiled) +//*/ +//function phpbb_create_dumped_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) +//{ +// // Check for our cached container; if it exists, use it +// $container_filename = phpbb_container_filename($phpbb_root_path, $php_ext); +// if (file_exists($container_filename)) +// { +// require($container_filename); +// return new phpbb_cache_container(); +// } +// +// $container = phpbb_create_compiled_container($config_file, $extensions, $passes, $phpbb_root_path, $php_ext); +// +// // Lastly, we create our cached container class +// $dumper = new PhpDumper($container); +// $cached_container_dump = $dumper->dump(array( +// 'class' => 'phpbb_cache_container', +// 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', +// )); +// +// file_put_contents($container_filename, $cached_container_dump); +// +// return $container; +//} +// +///** +//* Create an environment-specific ContainerBuilder object +//* +//* If debug is enabled, the container is re-compiled every time. +//* This ensures that the latest changes will always be reflected +//* during development. +//* +//* Otherwise it will get the existing dumped container and use +//* that one instead. +//* +//* @param array $extensions Array of Container extension objects +//* @param array $passes Array of Compiler Pass objects +//* @param string $phpbb_root_path Root path +//* @param string $php_ext PHP Extension +//* @return ContainerBuilder object (compiled) +//*/ +//function phpbb_create_dumped_container_unless_debug($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) +//{ +// $container_factory = defined('DEBUG_CONTAINER') ? 'phpbb_create_compiled_container' : 'phpbb_create_dumped_container'; +// return $container_factory($config_file, $extensions, $passes, $phpbb_root_path, $php_ext); +//} +// +///** +//* Create a default ContainerBuilder object +//* +//* Contains the default configuration of the phpBB container. +//* +//* @param array $extensions Array of Container extension objects +//* @param array $passes Array of Compiler Pass objects +//* @return ContainerBuilder object (compiled) +//*/ +//function phpbb_create_default_container($phpbb_root_path, $php_ext) +//{ +// $config_file = $phpbb_root_path . 'config.' . $php_ext; +// $installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path); +// +// return phpbb_create_dumped_container_unless_debug( +// $config_file, +// array( +// new \phpbb\di\extension\config($config_file), +// new \phpbb\di\extension\core($phpbb_root_path . 'config'), +// new \phpbb\di\extension\ext($installed_exts), +// ), +// array( +// new \phpbb\di\pass\collection_pass(), +// new \phpbb\di\pass\kernel_pass(), +// ), +// $phpbb_root_path, +// $php_ext +// ); +//} +// +///** +//* Get the filename under which the dumped container will be stored. +//* +//* @param string $phpbb_root_path Root path +//* @param string $php_ext PHP Extension +//* @return Path for dumped container +//*/ +//function phpbb_container_filename($phpbb_root_path, $php_ext) +//{ +// $filename = str_replace(array('/', '.'), array('slash', 'dot'), $phpbb_root_path); +// return $phpbb_root_path . 'cache/container_' . $filename . '.' . $php_ext; +//} -- cgit v1.2.1 From 1d966fbc86db47c3518b35de849cad3a1f295e71 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 28 Jun 2014 01:36:59 +0200 Subject: [ticket/12775] Add tests for the container factory PHPBB3-12775 --- phpBB/includes/functions_container.php | 291 --------------------------------- 1 file changed, 291 deletions(-) delete mode 100644 phpBB/includes/functions_container.php (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php deleted file mode 100644 index 96086a59ed..0000000000 --- a/phpBB/includes/functions_container.php +++ /dev/null @@ -1,291 +0,0 @@ - -//* @license GNU General Public License, version 2 (GPL-2.0) -//* -//* For full copyright and license information, please see -//* the docs/CREDITS.txt file. -//* -//*/ -// -//use Symfony\Component\Config\FileLocator; -//use Symfony\Component\DependencyInjection\ContainerBuilder; -//use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -//use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -// -///** -//* @ignore -//*/ -//if (!defined('IN_PHPBB')) -//{ -// exit; -//} -// -///** -//* Get DB connection from config.php. -//* -//* Used to bootstrap the container. -//* -//* @param string $config_file -//* @return \phpbb\db\driver\driver_interface -//*/ -//function phpbb_bootstrap_db_connection($config_file) -//{ -// require($config_file); -// $dbal_driver_class = phpbb_convert_30_dbms_to_31($dbms); -// -// $db = new $dbal_driver_class(); -// $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, defined('PHPBB_DB_NEW_LINK')); -// -// return $db; -//} -// -///** -//* Get table prefix from config.php. -//* -//* Used to bootstrap the container. -//* -//* @param string $config_file -//* @return string table prefix -//*/ -//function phpbb_bootstrap_table_prefix($config_file) -//{ -// require($config_file); -// return $table_prefix; -//} -// -///** -//* Get enabled extensions. -//* -//* Used to bootstrap the container. -//* -//* @param string $config_file -//* @param string $phpbb_root_path -//* @return array enabled extensions -//*/ -//function phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path) -//{ -// $db = phpbb_bootstrap_db_connection($config_file); -// $table_prefix = phpbb_bootstrap_table_prefix($config_file); -// $extension_table = $table_prefix.'ext'; -// -// $sql = 'SELECT * -// FROM ' . $extension_table . ' -// WHERE ext_active = 1'; -// -// $result = $db->sql_query($sql); -// $rows = $db->sql_fetchrowset($result); -// $db->sql_freeresult($result); -// -// $exts = array(); -// foreach ($rows as $row) -// { -// $exts[$row['ext_name']] = $phpbb_root_path . 'ext/' . $row['ext_name'] . '/'; -// } -// -// return $exts; -//} -// -///** -//* Create the ContainerBuilder object -//* -//* @param array $extensions Array of Container extension objects -//* @param string $phpbb_root_path Root path -//* @param string $php_ext PHP Extension -//* @return ContainerBuilder object -//*/ -//function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext) -//{ -// $container = new ContainerBuilder(); -// -// foreach ($extensions as $extension) -// { -// $container->registerExtension($extension); -// $container->loadFromExtension($extension->getAlias()); -// } -// -// $container->setParameter('core.root_path', $phpbb_root_path); -// $container->setParameter('core.php_ext', $php_ext); -// -// return $container; -//} -// -///** -//* Create installer container -//* -//* @param string $phpbb_root_path Root path -//* @param string $php_ext PHP Extension -//* @return ContainerBuilder object -//*/ -//function phpbb_create_install_container($phpbb_root_path, $php_ext) -//{ -// $other_config_path = $phpbb_root_path . 'install/update/new/config/'; -// $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; -// -// $core = new \phpbb\di\extension\core($config_path); -// $container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext); -// -// $container->setParameter('core.root_path', $phpbb_root_path); -// $container->setParameter('core.adm_relative_path', $phpbb_adm_relative_path); -// $container->setParameter('core.php_ext', $php_ext); -// $container->setParameter('core.table_prefix', ''); -// -// $container->register('dbal.conn')->setSynthetic(true); -// -// $container->setAlias('cache.driver', 'cache.driver.install'); -// -// $container->compile(); -// -// return $container; -//} -// -///** -//* Create updater container -//* -//* @param string $phpbb_root_path Root path -//* @param string $php_ext PHP Extension -//* @param array $config_path Path to config directory -//* @return ContainerBuilder object (compiled) -//*/ -//function phpbb_create_update_container($phpbb_root_path, $php_ext, $config_path) -//{ -// $config_file = $phpbb_root_path . 'config.' . $php_ext; -// return phpbb_create_compiled_container( -// $config_file, -// array( -// new phpbb\di\extension\config($config_file), -// new phpbb\di\extension\core($config_path), -// ), -// array( -// new phpbb\di\pass\collection_pass(), -// new phpbb\di\pass\kernel_pass(), -// ), -// $phpbb_root_path, -// $php_ext -// ); -//} -// -///** -//* Create a compiled ContainerBuilder object -//* -//* @param array $extensions Array of Container extension objects -//* @param array $passes Array of Compiler Pass objects -//* @param string $phpbb_root_path Root path -//* @param string $php_ext PHP Extension -//* @return ContainerBuilder object (compiled) -//*/ -//function phpbb_create_compiled_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) -//{ -// // Create the final container to be compiled and cached -// $container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext); -// -// // Compile the container -// foreach ($passes as $pass) -// { -// $container->addCompilerPass($pass); -// } -// $container->compile(); -// -// return $container; -//} -// -///** -//* Create a compiled and dumped ContainerBuilder object -//* -//* @param array $extensions Array of Container extension objects -//* @param array $passes Array of Compiler Pass objects -//* @param string $phpbb_root_path Root path -//* @param string $php_ext PHP Extension -//* @return ContainerBuilder object (compiled) -//*/ -//function phpbb_create_dumped_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) -//{ -// // Check for our cached container; if it exists, use it -// $container_filename = phpbb_container_filename($phpbb_root_path, $php_ext); -// if (file_exists($container_filename)) -// { -// require($container_filename); -// return new phpbb_cache_container(); -// } -// -// $container = phpbb_create_compiled_container($config_file, $extensions, $passes, $phpbb_root_path, $php_ext); -// -// // Lastly, we create our cached container class -// $dumper = new PhpDumper($container); -// $cached_container_dump = $dumper->dump(array( -// 'class' => 'phpbb_cache_container', -// 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder', -// )); -// -// file_put_contents($container_filename, $cached_container_dump); -// -// return $container; -//} -// -///** -//* Create an environment-specific ContainerBuilder object -//* -//* If debug is enabled, the container is re-compiled every time. -//* This ensures that the latest changes will always be reflected -//* during development. -//* -//* Otherwise it will get the existing dumped container and use -//* that one instead. -//* -//* @param array $extensions Array of Container extension objects -//* @param array $passes Array of Compiler Pass objects -//* @param string $phpbb_root_path Root path -//* @param string $php_ext PHP Extension -//* @return ContainerBuilder object (compiled) -//*/ -//function phpbb_create_dumped_container_unless_debug($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) -//{ -// $container_factory = defined('DEBUG_CONTAINER') ? 'phpbb_create_compiled_container' : 'phpbb_create_dumped_container'; -// return $container_factory($config_file, $extensions, $passes, $phpbb_root_path, $php_ext); -//} -// -///** -//* Create a default ContainerBuilder object -//* -//* Contains the default configuration of the phpBB container. -//* -//* @param array $extensions Array of Container extension objects -//* @param array $passes Array of Compiler Pass objects -//* @return ContainerBuilder object (compiled) -//*/ -//function phpbb_create_default_container($phpbb_root_path, $php_ext) -//{ -// $config_file = $phpbb_root_path . 'config.' . $php_ext; -// $installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path); -// -// return phpbb_create_dumped_container_unless_debug( -// $config_file, -// array( -// new \phpbb\di\extension\config($config_file), -// new \phpbb\di\extension\core($phpbb_root_path . 'config'), -// new \phpbb\di\extension\ext($installed_exts), -// ), -// array( -// new \phpbb\di\pass\collection_pass(), -// new \phpbb\di\pass\kernel_pass(), -// ), -// $phpbb_root_path, -// $php_ext -// ); -//} -// -///** -//* Get the filename under which the dumped container will be stored. -//* -//* @param string $phpbb_root_path Root path -//* @param string $php_ext PHP Extension -//* @return Path for dumped container -//*/ -//function phpbb_container_filename($phpbb_root_path, $php_ext) -//{ -// $filename = str_replace(array('/', '.'), array('slash', 'dot'), $phpbb_root_path); -// return $phpbb_root_path . 'cache/container_' . $filename . '.' . $php_ext; -//} -- cgit v1.2.1 From ed812a9dfb59b1eb83263adbaa52723ff826a791 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 21:58:17 +0200 Subject: [ticket/12775] Move phpbb_convert_30_dbms_to_31 into the config file class PHPBB3-12775 --- phpBB/includes/functions.php | 46 -------------------------- phpBB/includes/questionnaire/questionnaire.php | 7 ++-- 2 files changed, 5 insertions(+), 48 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9d5770069d..158bf1cbc0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5326,52 +5326,6 @@ function phpbb_to_numeric($input) return ($input > PHP_INT_MAX) ? (float) $input : (int) $input; } -/** -* Convert either 3.0 dbms or 3.1 db driver class name to 3.1 db driver class name. -* -* If $dbms is a valid 3.1 db driver class name, returns it unchanged. -* Otherwise prepends phpbb\db\driver\ to the dbms to convert a 3.0 dbms -* to 3.1 db driver class name. -* -* @param string $dbms dbms parameter -* @return db driver class -*/ -function phpbb_convert_30_dbms_to_31($dbms) -{ - // Note: this check is done first because mysqli extension - // supplies a mysqli class, and class_exists($dbms) would return - // true for mysqli class. - // However, per the docblock any valid 3.1 driver name should be - // recognized by this function, and have priority over 3.0 dbms. - if (strpos($dbms, 'phpbb\db\driver') === false && class_exists('phpbb\db\driver\\' . $dbms)) - { - return 'phpbb\db\driver\\' . $dbms; - } - - if (class_exists($dbms)) - { - // Additionally we could check that $dbms extends phpbb\db\driver\driver. - // http://php.net/manual/en/class.reflectionclass.php - // Beware of possible performance issues: - // http://stackoverflow.com/questions/294582/php-5-reflection-api-performance - // We could check for interface implementation in all paths or - // only when we do not prepend phpbb\db\driver\. - - /* - $reflection = new \ReflectionClass($dbms); - - if ($reflection->isSubclassOf('phpbb\db\driver\driver')) - { - return $dbms; - } - */ - - return $dbms; - } - - throw new \RuntimeException("You have specified an invalid dbms driver: $dbms"); -} - /** * Get the board contact details (e.g. for emails) * diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index b4b01a74bf..302419618e 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -258,10 +258,13 @@ class phpbb_questionnaire_phpbb_data_provider function get_data() { global $phpbb_root_path, $phpEx; - include("{$phpbb_root_path}config.$phpEx"); + + $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); + $phpbb_config_php_file->set_config_file($phpbb_root_path . 'config.' . $phpEx); + extract($phpbb_config_php_file->get_all()); unset($dbhost, $dbport, $dbname, $dbuser, $dbpasswd); // Just a precaution - $dbms = phpbb_convert_30_dbms_to_31($dbms); + $dbms = $phpbb_config_php_file->convert_30_dbms_to_31($dbms); // Only send certain config vars $config_vars = array( -- cgit v1.2.1 From d226a73111063194bac700c4236cb43dacd3ffc7 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 30 Jun 2014 00:51:01 +0200 Subject: [ticket/12775] Remove useless includes of config.php PHPBB3-12775 --- phpBB/includes/questionnaire/questionnaire.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index 302419618e..63ea432863 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -257,10 +257,8 @@ class phpbb_questionnaire_phpbb_data_provider */ function get_data() { - global $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx, $phpbb_config_php_file; - $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); - $phpbb_config_php_file->set_config_file($phpbb_root_path . 'config.' . $phpEx); extract($phpbb_config_php_file->get_all()); unset($dbhost, $dbport, $dbname, $dbuser, $dbpasswd); // Just a precaution -- cgit v1.2.1