Merge branch '3.2.x'

This commit is contained in:
Marc Alexander 2016-03-24 21:15:21 +01:00
commit 5bb1a98125
18 changed files with 43 additions and 48 deletions

View file

@ -75,6 +75,7 @@ services:
- '%core.root_path%' - '%core.root_path%'
- '%core.php_ext%' - '%core.php_ext%'
- '@config' - '@config'
- '%core.cache_dir%'
calls: calls:
- [set_name, [cron.task.core.queue]] - [set_name, [cron.task.core.queue]]
tags: tags:

View file

@ -5,9 +5,8 @@ services:
- '@service_container' - '@service_container'
- '@routing.chained_resources_locator' - '@routing.chained_resources_locator'
- '@routing.delegated_loader' - '@routing.delegated_loader'
- '%core.root_path%'
- '%core.php_ext%' - '%core.php_ext%'
- '%core.environment%' - '%core.cache_dir%'
router.listener: router.listener:
class: Symfony\Component\HttpKernel\EventListener\RouterListener class: Symfony\Component\HttpKernel\EventListener\RouterListener

View file

@ -1,5 +1,5 @@
parameters: parameters:
text_formatter.cache.dir: '%core.root_path%cache/%core.environment%/' text_formatter.cache.dir: '%core.cache_dir%'
text_formatter.cache.parser.key: _text_formatter_parser text_formatter.cache.parser.key: _text_formatter_parser
text_formatter.cache.renderer.key: _text_formatter_renderer text_formatter.cache.renderer.key: _text_formatter_renderer

View file

@ -1,5 +1,5 @@
parameters: parameters:
core.template.cache_path: '%core.root_path%cache/%core.environment%/twig/' core.template.cache_path: '%core.cache_dir%twig/'
services: services:
template.twig.environment: template.twig.environment:

View file

@ -12,7 +12,7 @@ services:
cache.driver: cache.driver:
class: '%cache.driver.class%' class: '%cache.driver.class%'
arguments: arguments:
- '%core.root_path%/cache/installer/' - '%core.cache_dir%'
config: config:
class: phpbb\config\config class: phpbb\config\config

View file

@ -155,13 +155,13 @@ class bbcode
$phpbb_container->get('filesystem'), $phpbb_container->get('filesystem'),
$phpbb_container->get('path_helper'), $phpbb_container->get('path_helper'),
$phpbb_container, $phpbb_container,
$phpbb_container->getParameter('core.root_path') . 'cache/', $phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('ext.manager'), $phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader( new \phpbb\template\twig\loader(
$phpbb_filesystem $phpbb_filesystem
) )
), ),
$phpbb_container->getParameter('core.root_path') . 'cache/', $phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('user'), $phpbb_container->get('user'),
$phpbb_container->get('template.twig.extensions.collection'), $phpbb_container->get('template.twig.extensions.collection'),
$phpbb_extension_manager $phpbb_extension_manager

View file

@ -640,13 +640,13 @@ class messenger
$phpbb_container->get('filesystem'), $phpbb_container->get('filesystem'),
$phpbb_container->get('path_helper'), $phpbb_container->get('path_helper'),
$phpbb_container, $phpbb_container,
$phpbb_container->getParameter('core.root_path') . 'cache/', $phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('ext.manager'), $phpbb_container->get('ext.manager'),
new \phpbb\template\twig\loader( new \phpbb\template\twig\loader(
$phpbb_filesystem $phpbb_filesystem
) )
), ),
$phpbb_container->getParameter('core.root_path') . 'cache/', $phpbb_container->getParameter('core.cache_dir'),
$phpbb_container->get('user'), $phpbb_container->get('user'),
$phpbb_container->get('template.twig.extensions.collection'), $phpbb_container->get('template.twig.extensions.collection'),
$phpbb_extension_manager $phpbb_extension_manager

View file

@ -1044,7 +1044,7 @@ class convertor
OR config_name = 'convert_db_user'"); OR config_name = 'convert_db_user'");
$db->sql_query('DELETE FROM ' . SESSIONS_TABLE); $db->sql_query('DELETE FROM ' . SESSIONS_TABLE);
@unlink($phpbb_root_path . 'cache/data_global.' . $phpEx); @unlink($phpbb_container->getParameter('core.cache_dir') . 'data_global.' . $phpEx);
phpbb_cache_moderators($db, $cache, $auth); phpbb_cache_moderators($db, $cache, $auth);
// And finally, add a note to the log // And finally, add a note to the log

View file

@ -32,9 +32,9 @@ class file extends \phpbb\cache\driver\base
*/ */
function __construct($cache_dir = null) function __construct($cache_dir = null)
{ {
global $phpbb_root_path, $phpbb_container; global $phpbb_container;
$this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_root_path . 'cache/' . $phpbb_container->getParameter('core.environment') . '/'; $this->cache_dir = !is_null($cache_dir) ? $cache_dir : $phpbb_container->getParameter('core.cache_dir');
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem();
if (!is_dir($this->cache_dir)) if (!is_dir($this->cache_dir))

View file

@ -25,9 +25,9 @@ abstract class memory extends \phpbb\cache\driver\base
*/ */
function __construct() function __construct()
{ {
global $phpbb_root_path, $dbname, $table_prefix; global $phpbb_root_path, $dbname, $table_prefix, $phpbb_container;
$this->cache_dir = $phpbb_root_path . 'cache/'; $this->cache_dir = $phpbb_container->getParameter('core.cache_dir');
$this->key_prefix = substr(md5($dbname . $table_prefix), 0, 8) . '_'; $this->key_prefix = substr(md5($dbname . $table_prefix), 0, 8) . '_';
if (!isset($this->extension) || !extension_loaded($this->extension)) if (!isset($this->extension) || !extension_loaded($this->extension))

View file

@ -20,20 +20,23 @@ class queue extends \phpbb\cron\task\base
{ {
protected $phpbb_root_path; protected $phpbb_root_path;
protected $php_ext; protected $php_ext;
protected $cache_dir;
protected $config; protected $config;
/** /**
* Constructor. * Constructor.
* *
* @param string $phpbb_root_path The root path * @param string $phpbb_root_path The root path
* @param string $php_ext PHP file extension * @param string $php_ext PHP file extension
* @param \phpbb\config\config $config The config * @param \phpbb\config\config $config The config
*/ * @param string $cache_dir phpBB cache directory
public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config) */
public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, $cache_dir)
{ {
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
$this->config = $config; $this->config = $config;
$this->cache_dir = $cache_dir;
} }
/** /**
@ -60,7 +63,7 @@ class queue extends \phpbb\cron\task\base
*/ */
public function is_runnable() public function is_runnable()
{ {
return file_exists($this->phpbb_root_path . 'cache/queue.' . $this->php_ext); return file_exists($this->cache_dir . 'queue.' . $this->php_ext);
} }
/** /**

View file

@ -522,6 +522,7 @@ class container_builder
'core.php_ext' => $this->php_ext, 'core.php_ext' => $this->php_ext,
'core.environment' => $this->get_environment(), 'core.environment' => $this->get_environment(),
'core.debug' => defined('DEBUG') ? DEBUG : false, 'core.debug' => defined('DEBUG') ? DEBUG : false,
'core.cache_dir' => $this->get_cache_dir(),
), ),
$this->get_env_parameters() $this->get_env_parameters()
); );

View file

@ -48,13 +48,6 @@ class router implements RouterInterface
*/ */
protected $loader; protected $loader;
/**
* phpBB root path
*
* @var string
*/
protected $phpbb_root_path;
/** /**
* PHP file extensions * PHP file extensions
* *
@ -62,13 +55,6 @@ class router implements RouterInterface
*/ */
protected $php_ext; protected $php_ext;
/**
* Name of the current environment
*
* @var string
*/
protected $environment;
/** /**
* @var \Symfony\Component\Routing\Matcher\UrlMatcherInterface|null * @var \Symfony\Component\Routing\Matcher\UrlMatcherInterface|null
*/ */
@ -89,25 +75,28 @@ class router implements RouterInterface
*/ */
protected $route_collection; protected $route_collection;
/**
* @var string
*/
protected $cache_dir;
/** /**
* Construct method * Construct method
* *
* @param ContainerInterface $container DI container * @param ContainerInterface $container DI container
* @param resources_locator_interface $resources_locator Resources locator * @param resources_locator_interface $resources_locator Resources locator
* @param LoaderInterface $loader Resources loader * @param LoaderInterface $loader Resources loader
* @param string $phpbb_root_path phpBB root path
* @param string $php_ext PHP file extension * @param string $php_ext PHP file extension
* @param string $environment Name of the current environment * @param string $cache_dir phpBB cache directory
*/ */
public function __construct(ContainerInterface $container, resources_locator_interface $resources_locator, LoaderInterface $loader, $phpbb_root_path, $php_ext, $environment) public function __construct(ContainerInterface $container, resources_locator_interface $resources_locator, LoaderInterface $loader, $php_ext, $cache_dir)
{ {
$this->container = $container; $this->container = $container;
$this->resources_locator = $resources_locator; $this->resources_locator = $resources_locator;
$this->loader = $loader; $this->loader = $loader;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext; $this->php_ext = $php_ext;
$this->environment = $environment;
$this->context = new RequestContext(); $this->context = new RequestContext();
$this->cache_dir = $cache_dir;
} }
/** /**
@ -211,7 +200,7 @@ class router implements RouterInterface
{ {
try try
{ {
$cache = new ConfigCache("{$this->phpbb_root_path}cache/{$this->environment}/url_matcher.{$this->php_ext}", defined('DEBUG')); $cache = new ConfigCache("{$this->cache_dir}url_matcher.{$this->php_ext}", defined('DEBUG'));
if (!$cache->isFresh()) if (!$cache->isFresh())
{ {
$dumper = new PhpMatcherDumper($this->get_routes()); $dumper = new PhpMatcherDumper($this->get_routes());
@ -266,7 +255,7 @@ class router implements RouterInterface
{ {
try try
{ {
$cache = new ConfigCache("{$this->phpbb_root_path}cache/{$this->environment}/url_generator.{$this->php_ext}", defined('DEBUG')); $cache = new ConfigCache("{$this->cache_dir}url_generator.{$this->php_ext}", defined('DEBUG'));
if (!$cache->isFresh()) if (!$cache->isFresh())
{ {
$dumper = new PhpGeneratorDumper($this->get_routes()); $dumper = new PhpGeneratorDumper($this->get_routes());

View file

@ -126,7 +126,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/') new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/')
); );
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager);
$this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php');
// Set correct current phpBB root path // Set correct current phpBB root path
$this->root_path = $this->get_phpbb_root_path(); $this->root_path = $this->get_phpbb_root_path();

View file

@ -47,7 +47,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/') new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/')
); );
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager);
$router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php');
$routes = $router->get_routes(); $routes = $router->get_routes();
// This will need to be updated if any new routes are defined // This will need to be updated if any new routes are defined

View file

@ -46,7 +46,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/') new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/')
); );
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager);
$router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php');
$request = new phpbb_mock_request(); $request = new phpbb_mock_request();
$request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER); $request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER);

View file

@ -73,7 +73,7 @@ class phpbb_session_testable_factory
public function get_session(\phpbb\db\driver\driver_interface $dbal) public function get_session(\phpbb\db\driver\driver_interface $dbal)
{ {
// set up all the global variables used by session // set up all the global variables used by session
global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container; global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container, $phpbb_root_path;
$request = $this->request = new phpbb_mock_request( $request = $this->request = new phpbb_mock_request(
array(), array(),
@ -95,6 +95,7 @@ class phpbb_session_testable_factory
new phpbb_mock_auth_provider() new phpbb_mock_auth_provider()
); );
$phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT);
$phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
$provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config);
$provider_collection->add('auth.provider.db'); $provider_collection->add('auth.provider.db');
$phpbb_container->set( $phpbb_container->set(

View file

@ -209,10 +209,11 @@ class phpbb_functional_test_case extends phpbb_test_case
{ {
if (!$this->cache) if (!$this->cache)
{ {
global $phpbb_container; global $phpbb_container, $phpbb_root_path;
$phpbb_container = new phpbb_mock_container_builder(); $phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT);
$phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
$this->cache = new \phpbb\cache\driver\file; $this->cache = new \phpbb\cache\driver\file;
} }