mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/14555] Uniformize cache directory usages
PHPBB3-14555
This commit is contained in:
parent
eca4726f3c
commit
56c2caf6c0
18 changed files with 43 additions and 48 deletions
|
@ -75,6 +75,7 @@ services:
|
|||
- '%core.root_path%'
|
||||
- '%core.php_ext%'
|
||||
- '@config'
|
||||
- '%core.cache_dir%'
|
||||
calls:
|
||||
- [set_name, [cron.task.core.queue]]
|
||||
tags:
|
||||
|
|
|
@ -5,9 +5,8 @@ services:
|
|||
- '@service_container'
|
||||
- '@routing.chained_resources_locator'
|
||||
- '@routing.delegated_loader'
|
||||
- '%core.root_path%'
|
||||
- '%core.php_ext%'
|
||||
- '%core.environment%'
|
||||
- '%core.cache_dir%'
|
||||
|
||||
router.listener:
|
||||
class: Symfony\Component\HttpKernel\EventListener\RouterListener
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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.renderer.key: _text_formatter_renderer
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
parameters:
|
||||
core.template.cache_path: '%core.root_path%cache/%core.environment%/twig/'
|
||||
core.template.cache_path: '%core.cache_dir%twig/'
|
||||
|
||||
services:
|
||||
template.twig.environment:
|
||||
|
|
|
@ -12,7 +12,7 @@ services:
|
|||
cache.driver:
|
||||
class: '%cache.driver.class%'
|
||||
arguments:
|
||||
- '%core.root_path%/cache/installer/'
|
||||
- '%core.cache_dir%'
|
||||
|
||||
config:
|
||||
class: phpbb\config\config
|
||||
|
|
|
@ -155,13 +155,13 @@ class bbcode
|
|||
$phpbb_container->get('filesystem'),
|
||||
$phpbb_container->get('path_helper'),
|
||||
$phpbb_container,
|
||||
$phpbb_container->getParameter('core.root_path') . 'cache/',
|
||||
$phpbb_container->getParameter('core.cache_dir'),
|
||||
$phpbb_container->get('ext.manager'),
|
||||
new \phpbb\template\twig\loader(
|
||||
$phpbb_filesystem
|
||||
)
|
||||
),
|
||||
$phpbb_container->getParameter('core.root_path') . 'cache/',
|
||||
$phpbb_container->getParameter('core.cache_dir'),
|
||||
$phpbb_container->get('user'),
|
||||
$phpbb_container->get('template.twig.extensions.collection'),
|
||||
$phpbb_extension_manager
|
||||
|
|
|
@ -640,13 +640,13 @@ class messenger
|
|||
$phpbb_container->get('filesystem'),
|
||||
$phpbb_container->get('path_helper'),
|
||||
$phpbb_container,
|
||||
$phpbb_container->getParameter('core.root_path') . 'cache/',
|
||||
$phpbb_container->getParameter('core.cache_dir'),
|
||||
$phpbb_container->get('ext.manager'),
|
||||
new \phpbb\template\twig\loader(
|
||||
$phpbb_filesystem
|
||||
)
|
||||
),
|
||||
$phpbb_container->getParameter('core.root_path') . 'cache/',
|
||||
$phpbb_container->getParameter('core.cache_dir'),
|
||||
$phpbb_container->get('user'),
|
||||
$phpbb_container->get('template.twig.extensions.collection'),
|
||||
$phpbb_extension_manager
|
||||
|
|
|
@ -1044,7 +1044,7 @@ class convertor
|
|||
OR config_name = 'convert_db_user'");
|
||||
$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);
|
||||
|
||||
// And finally, add a note to the log
|
||||
|
|
4
phpBB/phpbb/cache/driver/file.php
vendored
4
phpBB/phpbb/cache/driver/file.php
vendored
|
@ -32,9 +32,9 @@ class file extends \phpbb\cache\driver\base
|
|||
*/
|
||||
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();
|
||||
|
||||
if (!is_dir($this->cache_dir))
|
||||
|
|
4
phpBB/phpbb/cache/driver/memory.php
vendored
4
phpBB/phpbb/cache/driver/memory.php
vendored
|
@ -25,9 +25,9 @@ abstract class memory extends \phpbb\cache\driver\base
|
|||
*/
|
||||
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) . '_';
|
||||
|
||||
if (!isset($this->extension) || !extension_loaded($this->extension))
|
||||
|
|
|
@ -20,20 +20,23 @@ class queue extends \phpbb\cron\task\base
|
|||
{
|
||||
protected $phpbb_root_path;
|
||||
protected $php_ext;
|
||||
protected $cache_dir;
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $phpbb_root_path The root path
|
||||
* @param string $php_ext PHP file extension
|
||||
* @param \phpbb\config\config $config The config
|
||||
*/
|
||||
public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config)
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $phpbb_root_path The root path
|
||||
* @param string $php_ext PHP file extension
|
||||
* @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, $cache_dir)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->config = $config;
|
||||
$this->cache_dir = $cache_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +63,7 @@ class queue extends \phpbb\cron\task\base
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -522,6 +522,7 @@ class container_builder
|
|||
'core.php_ext' => $this->php_ext,
|
||||
'core.environment' => $this->get_environment(),
|
||||
'core.debug' => defined('DEBUG') ? DEBUG : false,
|
||||
'core.cache_dir' => $this->get_cache_dir(),
|
||||
),
|
||||
$this->get_env_parameters()
|
||||
);
|
||||
|
|
|
@ -48,13 +48,6 @@ class router implements RouterInterface
|
|||
*/
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* phpBB root path
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* PHP file extensions
|
||||
*
|
||||
|
@ -62,13 +55,6 @@ class router implements RouterInterface
|
|||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Name of the current environment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $environment;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Routing\Matcher\UrlMatcherInterface|null
|
||||
*/
|
||||
|
@ -89,25 +75,28 @@ class router implements RouterInterface
|
|||
*/
|
||||
protected $route_collection;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $cache_dir;
|
||||
|
||||
/**
|
||||
* Construct method
|
||||
*
|
||||
* @param ContainerInterface $container DI container
|
||||
* @param resources_locator_interface $resources_locator Resources locator
|
||||
* @param LoaderInterface $loader Resources loader
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @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->resources_locator = $resources_locator;
|
||||
$this->loader = $loader;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->environment = $environment;
|
||||
$this->context = new RequestContext();
|
||||
$this->cache_dir = $cache_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,7 +200,7 @@ class router implements RouterInterface
|
|||
{
|
||||
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())
|
||||
{
|
||||
$dumper = new PhpMatcherDumper($this->get_routes());
|
||||
|
@ -266,7 +255,7 @@ class router implements RouterInterface
|
|||
{
|
||||
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())
|
||||
{
|
||||
$dumper = new PhpGeneratorDumper($this->get_routes());
|
||||
|
|
|
@ -126,7 +126,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
|
|||
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);
|
||||
$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
|
||||
$this->root_path = $this->get_phpbb_root_path();
|
||||
|
|
|
@ -47,7 +47,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
|
|||
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);
|
||||
$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();
|
||||
|
||||
// This will need to be updated if any new routes are defined
|
||||
|
|
|
@ -46,7 +46,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
|
|||
new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/')
|
||||
);
|
||||
$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->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER);
|
||||
|
|
|
@ -73,7 +73,7 @@ class phpbb_session_testable_factory
|
|||
public function get_session(\phpbb\db\driver\driver_interface $dbal)
|
||||
{
|
||||
// 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(
|
||||
array(),
|
||||
|
@ -95,6 +95,7 @@ class phpbb_session_testable_factory
|
|||
new phpbb_mock_auth_provider()
|
||||
);
|
||||
$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->add('auth.provider.db');
|
||||
$phpbb_container->set(
|
||||
|
|
|
@ -209,10 +209,11 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
{
|
||||
if (!$this->cache)
|
||||
{
|
||||
global $phpbb_container;
|
||||
global $phpbb_container, $phpbb_root_path;
|
||||
|
||||
$phpbb_container = new phpbb_mock_container_builder();
|
||||
$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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue