aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/install/controller
diff options
context:
space:
mode:
authorMate Bartus <mate.bartus@gmail.com>2015-07-24 09:20:50 +0200
committerMate Bartus <mate.bartus@gmail.com>2015-10-17 23:05:57 +0200
commit8f5a0ad6f73e7b7757b02c827436384c96069b5a (patch)
tree87a16ddaa2f645d62728f0b4543199e43995bfeb /phpBB/phpbb/install/controller
parentf1047ac854baba4d1015cd9a555a523b3860f2c9 (diff)
downloadforums-8f5a0ad6f73e7b7757b02c827436384c96069b5a.tar
forums-8f5a0ad6f73e7b7757b02c827436384c96069b5a.tar.gz
forums-8f5a0ad6f73e7b7757b02c827436384c96069b5a.tar.bz2
forums-8f5a0ad6f73e7b7757b02c827436384c96069b5a.tar.xz
forums-8f5a0ad6f73e7b7757b02c827436384c96069b5a.zip
[ticket/14039] Revamp updater
PHPBB3-14039
Diffstat (limited to 'phpBB/phpbb/install/controller')
-rw-r--r--phpBB/phpbb/install/controller/archive_download.php92
-rw-r--r--phpBB/phpbb/install/controller/helper.php96
-rw-r--r--phpBB/phpbb/install/controller/install.php43
-rw-r--r--phpBB/phpbb/install/controller/update.php162
4 files changed, 335 insertions, 58 deletions
diff --git a/phpBB/phpbb/install/controller/archive_download.php b/phpBB/phpbb/install/controller/archive_download.php
new file mode 100644
index 0000000000..711e1f2f0c
--- /dev/null
+++ b/phpBB/phpbb/install/controller/archive_download.php
@@ -0,0 +1,92 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\install\controller;
+
+use phpbb\install\helper\config;
+use Symfony\Component\HttpFoundation\BinaryFileResponse;
+use Symfony\Component\HttpFoundation\ResponseHeaderBag;
+
+class archive_download
+{
+ /**
+ * @var config
+ */
+ protected $installer_config;
+
+ /**
+ * Constructor
+ *
+ * @param config $config
+ */
+ public function __construct(config $config)
+ {
+ $this->installer_config = $config;
+ $this->installer_config->load_config();
+ }
+
+ /**
+ * Sends response with the merge conflict archive
+ *
+ * Merge conflicts are always have to be resolved manually,
+ * so we use a different archive for that.
+ *
+ * @return BinaryFileResponse
+ */
+ public function conflict_archive()
+ {
+ $filename = $this->installer_config->get('update_file_conflict_archive', false);
+
+ if (!$filename)
+ {
+ die ('The requested file is not exist.');
+ }
+
+ return $this->send_response($filename);
+ }
+
+ /**
+ * Sends response with the updated files' archive
+ *
+ * @return BinaryFileResponse
+ */
+ public function update_archive()
+ {
+ $filename = $this->installer_config->get('update_file_archive', '');
+
+ if (!$filename)
+ {
+ die ('The requested file is not exist.');
+ }
+
+ return $this->send_response($filename);
+ }
+
+ /**
+ * Generates a download response
+ *
+ * @param string $filename Path to the file to download
+ *
+ * @return BinaryFileResponse Response object
+ */
+ private function send_response($filename)
+ {
+ $response = new BinaryFileResponse($filename);
+ $response->setContentDisposition(
+ ResponseHeaderBag::DISPOSITION_ATTACHMENT,
+ basename($filename)
+ );
+
+ return $response;
+ }
+}
diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php
index fdfa6821ed..ef6b8ba3c2 100644
--- a/phpBB/phpbb/install/controller/helper.php
+++ b/phpBB/phpbb/install/controller/helper.php
@@ -13,6 +13,7 @@
namespace phpbb\install\controller;
+use phpbb\install\helper\config;
use phpbb\install\helper\navigation\navigation_provider;
use phpbb\language\language;
use phpbb\language\language_file_helper;
@@ -34,6 +35,11 @@ use Symfony\Component\HttpFoundation\Cookie;
class helper
{
/**
+ * @var config
+ */
+ protected $installer_config;
+
+ /**
* @var \phpbb\language\language
*/
protected $language;
@@ -91,6 +97,7 @@ class helper
/**
* Constructor
*
+ * @param config $config
* @param language $language
* @param language_file_helper $lang_helper
* @param navigation_provider $nav
@@ -101,8 +108,9 @@ class helper
* @param router $router
* @param string $phpbb_root_path
*/
- public function __construct(language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, request $phpbb_request, symfony_request $request, router $router, $phpbb_root_path)
+ public function __construct(config $config, language $language, language_file_helper $lang_helper, navigation_provider $nav, template $template, path_helper $path_helper, request $phpbb_request, symfony_request $request, router $router, $phpbb_root_path)
{
+ $this->installer_config = $config;
$this->language = $language;
$this->language_cookie = false;
$this->lang_helper = $lang_helper;
@@ -200,6 +208,47 @@ class helper
}
/**
+ * Process navigation data to reflect active/completed stages
+ *
+ * @param \phpbb\install\helper\iohandler\iohandler_interface|null $iohandler
+ */
+ public function handle_navigation($iohandler = null)
+ {
+ $nav_data = $this->installer_config->get_navigation_data();
+
+ // Set active navigation stage
+ if (isset($nav_data['active']) && is_array($nav_data['active']))
+ {
+ if ($iohandler !== null)
+ {
+ $iohandler->set_active_stage_menu($nav_data['active']);
+ }
+
+ $this->navigation_provider->set_nav_property($nav_data['active'], array(
+ 'selected' => true,
+ 'completed' => false,
+ ));
+ }
+
+ // Set finished navigation stages
+ if (isset($nav_data['finished']) && is_array($nav_data['finished']))
+ {
+ foreach ($nav_data['finished'] as $finished_stage)
+ {
+ if ($iohandler !== null)
+ {
+ $iohandler->set_finished_stage_menu($finished_stage);
+ }
+
+ $this->navigation_provider->set_nav_property($finished_stage, array(
+ 'selected' => false,
+ 'completed' => true,
+ ));
+ }
+ }
+ }
+
+ /**
* Set default template variables
*
* @param string $page_title Title of the page
@@ -207,27 +256,32 @@ class helper
*/
protected function page_header($page_title, $selected_language = false)
{
+ // Path to templates
+ $paths = array($this->phpbb_root_path . 'install/update/new/adm/', $this->phpbb_admin_path);
+ $paths = array_filter($paths, 'is_dir');
+ $path = array_shift($paths);
+ $path = substr($path, strlen($this->phpbb_root_path));
+
$this->template->assign_vars(array(
- 'L_CHANGE' => $this->language->lang('CHANGE'),
- 'L_COLON' => $this->language->lang('COLON'),
- 'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'),
- 'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'),
- 'L_SKIP' => $this->language->lang('SKIP'),
- 'PAGE_TITLE' => $this->language->lang($page_title),
- 'T_IMAGE_PATH' => htmlspecialchars($this->phpbb_admin_path) . 'images/',
- 'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . 'assets/javascript/jquery.min.js',
- 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . 'adm/style',
- 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . 'assets/',
-
- 'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'),
- 'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right',
- 'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left',
- 'S_CONTENT_ENCODING' => 'UTF-8',
- 'S_LANG_SELECT' => $selected_language,
-
- 'S_USER_LANG' => $this->language->lang('USER_LANG'),
- )
- );
+ 'L_CHANGE' => $this->language->lang('CHANGE'),
+ 'L_COLON' => $this->language->lang('COLON'),
+ 'L_INSTALL_PANEL' => $this->language->lang('INSTALL_PANEL'),
+ 'L_SELECT_LANG' => $this->language->lang('SELECT_LANG'),
+ 'L_SKIP' => $this->language->lang('SKIP'),
+ 'PAGE_TITLE' => $this->language->lang($page_title),
+ 'T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . $path . 'images/',
+ 'T_JQUERY_LINK' => $this->path_helper->get_web_root_path() . $path . '../assets/javascript/jquery.min.js',
+ 'T_TEMPLATE_PATH' => $this->path_helper->get_web_root_path() . $path . 'style',
+ 'T_ASSETS_PATH' => $this->path_helper->get_web_root_path() . $path . '../assets/',
+
+ 'S_CONTENT_DIRECTION' => $this->language->lang('DIRECTION'),
+ 'S_CONTENT_FLOW_BEGIN' => ($this->language->lang('DIRECTION') === 'ltr') ? 'left' : 'right',
+ 'S_CONTENT_FLOW_END' => ($this->language->lang('DIRECTION') === 'ltr') ? 'right' : 'left',
+ 'S_CONTENT_ENCODING' => 'UTF-8',
+ 'S_LANG_SELECT' => $selected_language,
+
+ 'S_USER_LANG' => $this->language->lang('USER_LANG'),
+ ));
$this->render_navigation();
}
diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php
index 80f6651a39..8d5ff95958 100644
--- a/phpBB/phpbb/install/controller/install.php
+++ b/phpBB/phpbb/install/controller/install.php
@@ -13,7 +13,6 @@
namespace phpbb\install\controller;
-use phpbb\install\helper\config;
use phpbb\install\helper\install_helper;
use phpbb\install\helper\navigation\navigation_provider;
use Symfony\Component\HttpFoundation\StreamedResponse;
@@ -36,11 +35,6 @@ class install
protected $controller_helper;
/**
- * @var config
- */
- protected $installer_config;
-
- /**
* @var factory
*/
protected $iohandler_factory;
@@ -79,7 +73,6 @@ class install
* Constructor
*
* @param helper $helper
- * @param config $install_config
* @param factory $factory
* @param navigation_provider $nav_provider
* @param language $language
@@ -88,10 +81,9 @@ class install
* @param installer $installer
* @param install_helper $install_helper
*/
- public function __construct(helper $helper, config $install_config, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer, install_helper $install_helper)
+ public function __construct(helper $helper, factory $factory, navigation_provider $nav_provider, language $language, template $template, request_interface $request, installer $installer, install_helper $install_helper)
{
$this->controller_helper = $helper;
- $this->installer_config = $install_config;
$this->iohandler_factory = $factory;
$this->menu_provider = $nav_provider;
$this->language = $language;
@@ -130,34 +122,6 @@ class install
// Set the appropriate input-output handler
$this->installer->set_iohandler($this->iohandler_factory->get());
- // Set up navigation
- $nav_data = $this->installer_config->get_navigation_data();
- /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
- $iohandler = $this->iohandler_factory->get();
-
- // Set active navigation stage
- if (isset($nav_data['active']) && is_array($nav_data['active']))
- {
- $iohandler->set_active_stage_menu($nav_data['active']);
- $this->menu_provider->set_nav_property($nav_data['active'], array(
- 'selected' => true,
- 'completed' => false,
- ));
- }
-
- // Set finished navigation stages
- if (isset($nav_data['finished']) && is_array($nav_data['finished']))
- {
- foreach ($nav_data['finished'] as $finished_stage)
- {
- $iohandler->set_finished_stage_menu($finished_stage);
- $this->menu_provider->set_nav_property($finished_stage, array(
- 'selected' => false,
- 'completed' => true,
- ));
- }
- }
-
if ($this->request->is_ajax())
{
$installer = $this->installer;
@@ -193,6 +157,11 @@ class install
'TITLE' => $this->language->lang('INSTALL_INTRO'),
'CONTENT' => $this->language->lang('INSTALL_INTRO_BODY'),
));
+
+ /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
+ $iohandler = $this->iohandler_factory->get();
+ $this->controller_helper->handle_navigation($iohandler);
+
return $this->controller_helper->render('installer_install.html', 'INSTALL', true);
}
diff --git a/phpBB/phpbb/install/controller/update.php b/phpBB/phpbb/install/controller/update.php
new file mode 100644
index 0000000000..5212ba7f26
--- /dev/null
+++ b/phpBB/phpbb/install/controller/update.php
@@ -0,0 +1,162 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\install\controller;
+
+use phpbb\install\helper\install_helper;
+use phpbb\install\helper\iohandler\factory;
+use phpbb\install\helper\navigation\navigation_provider;
+use phpbb\install\installer;
+use phpbb\language\language;
+use phpbb\request\request_interface;
+use phpbb\template\template;
+use Symfony\Component\HttpFoundation\StreamedResponse;
+
+/**
+ * Updater controller
+ */
+class update
+{
+ /**
+ * @var helper
+ */
+ protected $controller_helper;
+
+ /**
+ * @var installer
+ */
+ protected $installer;
+
+ /**
+ * @var install_helper
+ */
+ protected $install_helper;
+
+ /**
+ * @var factory
+ */
+ protected $iohandler_factory;
+
+ /**
+ * @var language
+ */
+ protected $language;
+
+ /**
+ * @var navigation_provider
+ */
+ protected $menu_provider;
+
+ /**
+ * @var request_interface
+ */
+ protected $request;
+
+ /**
+ * @var template
+ */
+ protected $template;
+
+ /**
+ * Constructor
+ *
+ * @param helper $controller_helper
+ * @param installer $installer
+ * @param install_helper $install_helper
+ * @param factory $iohandler
+ * @param language $language
+ * @param navigation_provider $menu_provider
+ * @param request_interface $request
+ * @param template $template
+ */
+ public function __construct(helper $controller_helper, installer $installer, install_helper $install_helper, factory $iohandler, language $language, navigation_provider $menu_provider, request_interface $request, template $template)
+ {
+ $this->controller_helper = $controller_helper;
+ $this->installer = $installer;
+ $this->install_helper = $install_helper;
+ $this->iohandler_factory = $iohandler;
+ $this->language = $language;
+ $this->menu_provider = $menu_provider;
+ $this->request = $request;
+ $this->template = $template;
+ }
+
+ /**
+ * Controller entry point
+ */
+ public function handle()
+ {
+ if (!$this->install_helper->is_phpbb_installed())
+ {
+ die ('phpBB is not installed');
+ }
+
+ $this->template->assign_vars(array(
+ 'U_ACTION' => $this->controller_helper->route('phpbb_installer_update'),
+ ));
+
+ // Set up input-output handler
+ if ($this->request->is_ajax())
+ {
+ $this->iohandler_factory->set_environment('ajax');
+ }
+ else
+ {
+ $this->iohandler_factory->set_environment('nojs');
+ }
+
+ // Set the appropriate input-output handler
+ $this->installer->set_iohandler($this->iohandler_factory->get());
+
+ // Render the intro page
+ if ($this->request->is_ajax())
+ {
+ $installer = $this->installer;
+ $response = new StreamedResponse();
+ $response->setCallback(function() use ($installer) {
+ $installer->run();
+ });
+
+ // Try to bypass any server output buffers
+ $response->headers->set('X-Accel-Buffering', 'no');
+ $response->headers->set('Content-type', 'application/json');
+
+ return $response;
+ }
+ else
+ {
+ $this->controller_helper->handle_language_select();
+
+ // Set active stage
+ $this->menu_provider->set_nav_property(
+ array('update', 0, 'introduction'),
+ array(
+ 'selected' => true,
+ 'completed' => false,
+ )
+ );
+
+ $this->template->assign_vars(array(
+ 'SHOW_INSTALL_START_FORM' => true,
+ 'TITLE' => $this->language->lang('UPDATE_INSTALLATION'),
+ 'CONTENT' => $this->language->lang('UPDATE_INSTALLATION_EXPLAIN'),
+ ));
+
+ /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
+ $iohandler = $this->iohandler_factory->get();
+ $this->controller_helper->handle_navigation($iohandler);
+
+ return $this->controller_helper->render('installer_update.html', 'UPDATE_INSTALLATION', true);
+ }
+ }
+}