[ticket/14270] Purge cache when the installer is finished

PHPBB3-14270
This commit is contained in:
Mate Bartus 2015-11-04 17:25:38 +01:00
parent c783c37c73
commit 8d178f15f0
7 changed files with 26 additions and 9 deletions

View file

@ -9,6 +9,11 @@ imports:
- { resource: ../../default/container/services_twig.yml } - { resource: ../../default/container/services_twig.yml }
services: services:
cache.driver:
class: %cache.driver.class%
arguments:
- "%core.root_path%/cache/installer/"
config: config:
class: phpbb\config\config class: phpbb\config\config
arguments: arguments:

View file

@ -86,6 +86,7 @@ services:
class: phpbb\install\installer class: phpbb\install\installer
abstract: true abstract: true
arguments: arguments:
- @cache.driver
- @installer.helper.config - @installer.helper.config
- @path_helper - @path_helper

View file

@ -30,7 +30,6 @@ $phpbb_filesystem = $phpbb_installer_container->get('filesystem');
/** @var \phpbb\template\template $template */ /** @var \phpbb\template\template $template */
$template = $phpbb_installer_container->get('template'); $template = $phpbb_installer_container->get('template');
// Path to templates // Path to templates
$paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style');
$paths = array_filter($paths, 'is_dir'); $paths = array_filter($paths, 'is_dir');
@ -42,17 +41,17 @@ $template->set_custom_style(array(
), ),
), $paths); ), $paths);
/* @var $phpbb_dispatcher \phpbb\event\dispatcher */ /** @var $phpbb_dispatcher \phpbb\event\dispatcher */
$phpbb_dispatcher = $phpbb_installer_container->get('dispatcher'); $phpbb_dispatcher = $phpbb_installer_container->get('dispatcher');
/** @var \phpbb\language\language $language */ /** @var \phpbb\language\language $language */
$language = $phpbb_installer_container->get('language'); $language = $phpbb_installer_container->get('language');
$language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting')); $language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting'));
/* @var $http_kernel \Symfony\Component\HttpKernel\HttpKernel */ /** @var $http_kernel \Symfony\Component\HttpKernel\HttpKernel */
$http_kernel = $phpbb_installer_container->get('http_kernel'); $http_kernel = $phpbb_installer_container->get('http_kernel');
/* @var $symfony_request \phpbb\symfony_request */ /** @var $symfony_request \phpbb\symfony_request */
$symfony_request = $phpbb_installer_container->get('symfony_request'); $symfony_request = $phpbb_installer_container->get('symfony_request');
$response = $http_kernel->handle($symfony_request); $response = $http_kernel->handle($symfony_request);
$response->send(); $response->send();

View file

@ -81,4 +81,5 @@ $config_path = (file_exists($other_config_path . '/installer/config.yml')) ? $ot
$phpbb_installer_container = $phpbb_installer_container_builder $phpbb_installer_container = $phpbb_installer_container_builder
->with_config_path($config_path) ->with_config_path($config_path)
->with_custom_parameters(array('cache.driver.class' => 'phpbb\cache\driver\file'))
->get_container(); ->get_container();

View file

@ -13,6 +13,7 @@
namespace phpbb\install; namespace phpbb\install;
use phpbb\cache\driver\driver_interface;
use phpbb\di\ordered_service_collection; use phpbb\di\ordered_service_collection;
use phpbb\install\exception\installer_config_not_writable_exception; use phpbb\install\exception\installer_config_not_writable_exception;
use phpbb\install\exception\jump_to_restart_point_exception; use phpbb\install\exception\jump_to_restart_point_exception;
@ -25,6 +26,11 @@ use phpbb\path_helper;
class installer class installer
{ {
/**
* @var driver_interface
*/
protected $cache;
/** /**
* @var config * @var config
*/ */
@ -55,11 +61,13 @@ class installer
/** /**
* Constructor * Constructor
* *
* @param driver_interface $cache Cache service
* @param config $config Installer config handler * @param config $config Installer config handler
* @param path_helper $path_helper Path helper * @param path_helper $path_helper Path helper
*/ */
public function __construct(config $config, path_helper $path_helper) public function __construct(driver_interface $cache, config $config, path_helper $path_helper)
{ {
$this->cache = $cache;
$this->install_config = $config; $this->install_config = $config;
$this->installer_modules = null; $this->installer_modules = null;
$this->web_root = $path_helper->get_web_root_path(); $this->web_root = $path_helper->get_web_root_path();
@ -235,6 +243,7 @@ class installer
if ($install_finished || $fail_cleanup) if ($install_finished || $fail_cleanup)
{ {
$this->install_config->clean_up_config_file(); $this->install_config->clean_up_config_file();
$this->cache->purge();
} }
else else
{ {

View file

@ -295,7 +295,8 @@ class phpbb_functional_test_case extends phpbb_test_case
'installer.create_config_file.options' => [ 'installer.create_config_file.options' => [
'debug' => true, 'debug' => true,
'environment' => 'test', 'environment' => 'test',
] ],
'cache.driver.class' => 'phpbb\cache\driver\file'
]) ])
->without_compiled_container() ->without_compiled_container()
->get_container(); ->get_container();

View file

@ -128,7 +128,8 @@ class phpbb_ui_test_case extends phpbb_test_case
'installer.create_config_file.options' => [ 'installer.create_config_file.options' => [
'debug' => true, 'debug' => true,
'environment' => 'test', 'environment' => 'test',
] ],
'cache.driver.class' => 'phpbb\cache\driver\file'
]) ])
->without_compiled_container() ->without_compiled_container()
->get_container(); ->get_container();