aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/install
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/install')
-rw-r--r--phpBB/phpbb/install/console/command/install/install.php3
-rw-r--r--phpBB/phpbb/install/console/command/update/update.php3
-rw-r--r--phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php2
-rw-r--r--phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php8
-rw-r--r--phpBB/phpbb/install/helper/iohandler/cli_iohandler.php14
-rw-r--r--phpBB/phpbb/install/helper/iohandler/iohandler_base.php5
-rw-r--r--phpBB/phpbb/install/helper/iohandler/iohandler_interface.php15
-rw-r--r--phpBB/phpbb/install/installer.php17
-rw-r--r--phpBB/phpbb/install/installer_configuration.php4
-rw-r--r--phpBB/phpbb/install/module/install_data/task/create_search_index.php134
-rw-r--r--phpBB/phpbb/install/module/install_finish/task/install_extensions.php199
-rw-r--r--phpBB/phpbb/install/module/install_finish/task/populate_migrations.php1
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php2
-rw-r--r--phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php2
-rw-r--r--phpBB/phpbb/install/module/update_database/task/update.php2
-rw-r--r--phpBB/phpbb/install/module/update_database/task/update_extensions.php263
-rw-r--r--phpBB/phpbb/install/module/update_filesystem/task/diff_files.php71
-rw-r--r--phpBB/phpbb/install/module/update_filesystem/task/file_check.php32
-rw-r--r--phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php2
-rw-r--r--phpBB/phpbb/install/updater_configuration.php4
20 files changed, 748 insertions, 35 deletions
diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php
index de3a2e2d61..52a348fe44 100644
--- a/phpBB/phpbb/install/console/command/install/install.php
+++ b/phpBB/phpbb/install/console/command/install/install.php
@@ -151,6 +151,7 @@ class install extends \phpbb\console\command\command
try
{
$this->installer->run();
+ return 0;
}
catch (installer_exception $e)
{
@@ -203,5 +204,7 @@ class install extends \phpbb\console\command\command
$iohandler->set_input('server_port', $config['server']['server_port']);
$iohandler->set_input('script_path', $config['server']['script_path']);
$iohandler->set_input('submit_server', 'submit');
+
+ $iohandler->set_input('install-extensions', $config['extensions']);
}
}
diff --git a/phpBB/phpbb/install/console/command/update/update.php b/phpBB/phpbb/install/console/command/update/update.php
index 116f42f758..e827761d1c 100644
--- a/phpBB/phpbb/install/console/command/update/update.php
+++ b/phpBB/phpbb/install/console/command/update/update.php
@@ -151,6 +151,7 @@ class update extends \phpbb\console\command\command
try
{
$this->installer->run();
+ return 0;
}
catch (installer_exception $e)
{
@@ -175,5 +176,7 @@ class update extends \phpbb\console\command\command
$iohandler->set_input('submit_update_file', 'submit');
$iohandler->set_input('submit_continue_file_update', 'submit');
+
+ $iohandler->set_input('update-extensions', $config['extensions']);
}
}
diff --git a/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php b/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php
index 258a035768..5cdc331cbc 100644
--- a/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php
+++ b/phpBB/phpbb/install/helper/file_updater/ftp_file_updater.php
@@ -47,7 +47,7 @@ class ftp_file_updater implements file_updater_interface
* @param string $phpbb_root_path
* @param string $php_ext
*/
- public function __constructor(update_helper $update_helper, $phpbb_root_path, $php_ext)
+ public function __construct(update_helper $update_helper, $phpbb_root_path, $php_ext)
{
$this->transfer = null;
$this->update_helper = $update_helper;
diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php
index c168d26425..a40d457466 100644
--- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php
+++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php
@@ -123,6 +123,14 @@ class ajax_iohandler extends iohandler_base
/**
* {@inheritdoc}
*/
+ public function get_raw_input($name, $default)
+ {
+ return $this->request->raw_variable($name, $default);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function get_server_variable($name, $default = '')
{
return $this->request->server($name, $default);
diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php
index 196cdcdaab..4117a3dfd3 100644
--- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php
+++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php
@@ -74,6 +74,20 @@ class cli_iohandler extends iohandler_base
return $result;
}
+ /**
+ * {@inheritdoc}
+ */
+ public function get_raw_input($name, $default)
+ {
+ return $this->get_input($name, $default, true);
+ }
+
+ /**
+ * Set input variable
+ *
+ * @param string $name Name of input variable
+ * @param mixed $value Value of input variable
+ */
public function set_input($name, $value)
{
$this->input_values[$name] = $value;
diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php
index fed4bc101f..1797a6c9ad 100644
--- a/phpBB/phpbb/install/helper/iohandler/iohandler_base.php
+++ b/phpBB/phpbb/install/helper/iohandler/iohandler_base.php
@@ -71,6 +71,11 @@ abstract class iohandler_base implements iohandler_interface
protected $current_task_name;
/**
+ * @var bool
+ */
+ protected $restart_progress_bar;
+
+ /**
* Constructor
*/
public function __construct()
diff --git a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php
index f22f33d9cb..440748901c 100644
--- a/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php
+++ b/phpBB/phpbb/install/helper/iohandler/iohandler_interface.php
@@ -39,9 +39,20 @@ interface iohandler_interface
public function get_input($name, $default, $multibyte = false);
/**
+ * Returns raw input variable
+ *
+ * @param string $name Name of the input variable to obtain
+ * @param mixed $default A default value that is returned if the variable was not set.
+ * This function will always return a value of the same type as the default.
+ *
+ * @return mixed Value of the raw input variable
+ */
+ public function get_raw_input($name, $default);
+
+ /**
* Returns server variable
*
- * This function should work the same as request_interterface::server().
+ * This function should work the same as request_interface::server().
*
* @param string $name Name of the server variable
* @param mixed $default Default value to return when the requested variable does not exist
@@ -51,7 +62,7 @@ interface iohandler_interface
public function get_server_variable($name, $default = '');
/**
- * Wrapper function for request_interterface::header()
+ * Wrapper function for request_interface::header()
*
* @param string $name Name of the request header variable
* @param mixed $default Default value to return when the requested variable does not exist
diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php
index 240423ae78..e04e233a76 100644
--- a/phpBB/phpbb/install/installer.php
+++ b/phpBB/phpbb/install/installer.php
@@ -243,8 +243,21 @@ class installer
}
else
{
- global $SID;
- $acp_url = $this->web_root . 'adm/index.php' . $SID;
+ // Start session if not installing and get user object
+ // to allow redirecting to ACP
+ $user = $this->container_factory->get('user');
+ if (!isset($module) || !($module instanceof \phpbb\install\module\install_finish\module))
+ {
+ $auth = $this->container_factory->get('auth');
+
+ $user->session_begin();
+ $auth->acl($user->data);
+ $user->setup();
+ }
+
+ $phpbb_root_path = $this->container_factory->get_parameter('core.root_path');
+
+ $acp_url = append_sid($phpbb_root_path . 'adm/index.php', 'i=acp_help_phpbb&mode=help_phpbb', true, $user->session_id);
$this->iohandler->add_success_message('INSTALLER_FINISHED', array(
'ACP_LINK',
$acp_url,
diff --git a/phpBB/phpbb/install/installer_configuration.php b/phpBB/phpbb/install/installer_configuration.php
index c660c99d0f..805140338c 100644
--- a/phpBB/phpbb/install/installer_configuration.php
+++ b/phpBB/phpbb/install/installer_configuration.php
@@ -136,6 +136,10 @@ class installer_configuration implements ConfigurationInterface
->end()
->end()
->end()
+ ->arrayNode('extensions')
+ ->prototype('scalar')->end()
+ ->defaultValue([])
+ ->end()
->end()
;
return $treeBuilder;
diff --git a/phpBB/phpbb/install/module/install_data/task/create_search_index.php b/phpBB/phpbb/install/module/install_data/task/create_search_index.php
new file mode 100644
index 0000000000..8a2f6aa1de
--- /dev/null
+++ b/phpBB/phpbb/install/module/install_data/task/create_search_index.php
@@ -0,0 +1,134 @@
+<?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\module\install_data\task;
+
+use phpbb\auth\auth;
+use phpbb\db\driver\driver_interface;
+use phpbb\event\dispatcher;
+use phpbb\config\config;
+use phpbb\install\helper\container_factory;
+use phpbb\language\language;
+use phpbb\search\fulltext_native;
+use phpbb\user;
+
+class create_search_index extends \phpbb\install\task_base
+{
+ /**
+ * @var auth
+ */
+ protected $auth;
+
+ /**
+ * @var config
+ */
+ protected $config;
+
+ /**
+ * @var driver_interface
+ */
+ protected $db;
+
+ /**
+ * @var dispatcher
+ */
+ protected $phpbb_dispatcher;
+
+ /**
+ * @var language
+ */
+ protected $language;
+
+ /**
+ * @var user
+ */
+ protected $user;
+
+ /**
+ * @var string phpBB root path
+ */
+ protected $phpbb_root_path;
+
+ /**
+ * @var string PHP file extension
+ */
+ protected $php_ext;
+
+ /**
+ * Constructor
+ *
+ * @param config $config phpBB config
+ * @param container_factory $container Installer's DI container
+ * @param string $phpbb_root_path phpBB root path
+ * @param string $php_ext PHP file extension
+ */
+ public function __construct(config $config, container_factory $container,
+ $phpbb_root_path, $php_ext)
+ {
+ $this->auth = $container->get('auth');
+ $this->config = $config;
+ $this->db = $container->get('dbal.conn');
+ $this->language = $container->get('language');
+ $this->phpbb_dispatcher = $container->get('dispatcher');
+ $this->user = $container->get('user');
+
+ parent::__construct(true);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ // Make sure fulltext native load update is set
+ $this->config->set('fulltext_native_load_upd', 1);
+
+ $error = false;
+ $search = new fulltext_native(
+ $error,
+ $this->phpbb_root_path,
+ $this->php_ext,
+ $this->auth,
+ $this->config,
+ $this->db,
+ $this->user,
+ $this->phpbb_dispatcher
+ );
+
+ $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
+ FROM ' . POSTS_TABLE;
+ $result = $this->db->sql_query($sql);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
+ }
+ $this->db->sql_freeresult($result);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ static public function get_step_count()
+ {
+ return 1;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_task_lang_name()
+ {
+ return 'TASK_CREATE_SEARCH_INDEX';
+ }
+}
diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php
new file mode 100644
index 0000000000..553a30ea28
--- /dev/null
+++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php
@@ -0,0 +1,199 @@
+<?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\module\install_finish\task;
+
+use phpbb\install\exception\resource_limit_reached_exception;
+
+/**
+ * Installs extensions that exist in ext folder upon install
+ */
+class install_extensions extends \phpbb\install\task_base
+{
+ /**
+ * @var \phpbb\install\helper\config
+ */
+ protected $install_config;
+
+ /**
+ * @var \phpbb\install\helper\iohandler\iohandler_interface
+ */
+ protected $iohandler;
+
+ /**
+ * @var \phpbb\config\db
+ */
+ protected $config;
+
+ /**
+ * @var \phpbb\log\log_interface
+ */
+ protected $log;
+
+ /**
+ * @var \phpbb\user
+ */
+ protected $user;
+
+ /** @var \phpbb\extension\manager */
+ protected $extension_manager;
+
+ /** @var \Symfony\Component\Finder\Finder */
+ protected $finder;
+
+ /** @var string Extension table */
+ protected $extension_table;
+
+ /** @var \phpbb\db\driver\driver_interface */
+ protected $db;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\install\helper\container_factory $container
+ * @param \phpbb\install\helper\config $install_config
+ * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler
+ * @param string $phpbb_root_path phpBB root path
+ */
+ public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\install\helper\config $install_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, $phpbb_root_path)
+ {
+ $this->install_config = $install_config;
+ $this->iohandler = $iohandler;
+ $this->extension_table = $container->get_parameter('tables.ext');
+
+ $this->log = $container->get('log');
+ $this->user = $container->get('user');
+ $this->extension_manager = $container->get('ext.manager');
+ $this->config = $container->get('config');
+ $this->db = $container->get('dbal.conn');
+ $this->finder = new \Symfony\Component\Finder\Finder();
+ $this->finder->in($phpbb_root_path . 'ext/')
+ ->ignoreUnreadableDirs()
+ ->depth('< 3')
+ ->files()
+ ->name('composer.json');
+
+ // Make sure asset version exists in config. Otherwise we might try to
+ // insert the assets_version setting into the database and cause a
+ // duplicate entry error.
+ if (!isset($this->config['assets_version']))
+ {
+ $this->config['assets_version'] = 0;
+ }
+
+ parent::__construct(true);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ $this->user->session_begin();
+ $this->user->setup(array('common', 'acp/common', 'cli'));
+
+ $install_extensions = $this->iohandler->get_input('install-extensions', array());
+
+ $all_available_extensions = $this->extension_manager->all_available();
+ $i = $this->install_config->get('install_extensions_index', 0);
+ $available_extensions = array_slice($all_available_extensions, $i);
+
+ // Install extensions
+ foreach ($available_extensions as $ext_name => $ext_path)
+ {
+ if (!empty($install_extensions) && $install_extensions !== ['all'] && !in_array($ext_name, $install_extensions))
+ {
+ continue;
+ }
+
+ try
+ {
+ $this->extension_manager->enable($ext_name);
+ $extensions = $this->get_extensions();
+
+ if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active'])
+ {
+ // Create log
+ $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name));
+ $this->iohandler->add_success_message(array('CLI_EXTENSION_ENABLE_SUCCESS', $ext_name));
+ }
+ else
+ {
+ $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name));
+ }
+ }
+ catch (\Exception $e)
+ {
+ // Add fail log and continue
+ $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name));
+ }
+
+ $i++;
+
+ // Stop execution if resource limit is reached
+ if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
+ {
+ break;
+ }
+ }
+
+ $this->install_config->set('install_extensions_index', $i);
+
+ if ($i < sizeof($all_available_extensions))
+ {
+ throw new resource_limit_reached_exception();
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ static public function get_step_count()
+ {
+ return 1;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_task_lang_name()
+ {
+ return 'TASK_INSTALL_EXTENSIONS';
+ }
+
+ /**
+ * Get extensions from database
+ *
+ * @return array List of extensions
+ */
+ private function get_extensions()
+ {
+ $sql = 'SELECT *
+ FROM ' . $this->extension_table;
+
+ $result = $this->db->sql_query($sql);
+ $extensions_row = $this->db->sql_fetchrowset($result);
+ $this->db->sql_freeresult($result);
+
+ $extensions = array();
+
+ foreach ($extensions_row as $extension)
+ {
+ $extensions[$extension['ext_name']] = $extension;
+ }
+
+ ksort($extensions);
+
+ return $extensions;
+ }
+}
diff --git a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php
index 34541c361e..cebf0f425f 100644
--- a/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php
+++ b/phpBB/phpbb/install/module/install_finish/task/populate_migrations.php
@@ -70,6 +70,7 @@ class populate_migrations extends \phpbb\install\task_base
$migrations = $finder
->core_path('phpbb/db/migration/data/')
+ ->set_extensions(array())
->get_classes();
$this->migrator->populate_migrations($migrations);
}
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php
index ce720dbf76..dc7b060746 100644
--- a/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_database_data.php
@@ -79,7 +79,7 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in
$dbhost = $this->io_handler->get_input('dbhost', '', true);
$dbport = $this->io_handler->get_input('dbport', '');
$dbuser = $this->io_handler->get_input('dbuser', '');
- $dbpasswd = $this->io_handler->get_input('dbpasswd', '', true);
+ $dbpasswd = $this->io_handler->get_raw_input('dbpasswd', '');
$dbname = $this->io_handler->get_input('dbname', '');
$table_prefix = $this->io_handler->get_input('table_prefix', '');
diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php
index 1cb4f04297..e8a9c971b7 100644
--- a/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php
+++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_email_data.php
@@ -84,7 +84,7 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta
$email_form = array(
'email_enable' => array(
'label' => 'ENABLE_EMAIL',
- 'description' => 'COOKIE_SECURE_EXPLAIN',
+ 'description' => 'ENABLE_EMAIL_EXPLAIN',
'type' => 'radio',
'options' => array(
array(
diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php
index 9d7ba2f919..fb9eb44e6a 100644
--- a/phpBB/phpbb/install/module/update_database/task/update.php
+++ b/phpBB/phpbb/install/module/update_database/task/update.php
@@ -211,8 +211,6 @@ class update extends task_base
$this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL');
- $this->config->delete('version_update_from');
-
$this->cache->purge();
$this->config->increment('assets_version', 1);
diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php
new file mode 100644
index 0000000000..b66847b243
--- /dev/null
+++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php
@@ -0,0 +1,263 @@
+<?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\module\update_database\task;
+
+use phpbb\install\exception\resource_limit_reached_exception;
+use phpbb\install\helper\container_factory;
+use phpbb\install\helper\config;
+use phpbb\install\helper\iohandler\iohandler_interface;
+use phpbb\install\helper\update_helper;
+use phpbb\install\task_base;
+use Symfony\Component\Finder\Finder;
+
+/**
+ * Installs extensions that exist in ext folder upon install
+ */
+class update_extensions extends task_base
+{
+ /**
+ * @var \phpbb\cache\driver\driver_interface
+ */
+ protected $cache;
+
+ /**
+ * @var config
+ */
+ protected $install_config;
+
+ /**
+ * @var iohandler_interface
+ */
+ protected $iohandler;
+
+ /** @var update_helper */
+ protected $update_helper;
+
+ /**
+ * @var \phpbb\config\db
+ */
+ protected $config;
+
+ /**
+ * @var \phpbb\log\log_interface
+ */
+ protected $log;
+
+ /**
+ * @var \phpbb\user
+ */
+ protected $user;
+
+ /** @var \phpbb\extension\manager */
+ protected $extension_manager;
+
+ /** @var Finder */
+ protected $finder;
+
+ /** @var string Extension table */
+ protected $extension_table;
+
+ /** @var \phpbb\db\driver\driver_interface */
+ protected $db;
+
+ /**
+ * @var array List of default extensions to update, grouped by version
+ * they were added
+ */
+ static public $default_extensions_update = [
+ '3.2.0-RC2' => ['phpbb/viglink']
+ ];
+
+ /**
+ * Constructor
+ *
+ * @param container_factory $container
+ * @param config $install_config
+ * @param iohandler_interface $iohandler
+ * @param $update_helper $update_helper
+ * @param string $phpbb_root_path phpBB root path
+ */
+ public function __construct(container_factory $container, config $install_config, iohandler_interface $iohandler, update_helper $update_helper, $phpbb_root_path)
+ {
+ $this->install_config = $install_config;
+ $this->iohandler = $iohandler;
+ $this->extension_table = $container->get_parameter('tables.ext');
+
+ $this->log = $container->get('log');
+ $this->user = $container->get('user');
+ $this->extension_manager = $container->get('ext.manager');
+ $this->cache = $container->get('cache.driver');
+ $this->config = $container->get('config');
+ $this->db = $container->get('dbal.conn');
+ $this->update_helper = $update_helper;
+ $this->finder = new Finder();
+ $this->finder->in($phpbb_root_path . 'ext/')
+ ->ignoreUnreadableDirs()
+ ->depth('< 3')
+ ->files()
+ ->name('composer.json');
+
+ // Make sure asset version exists in config. Otherwise we might try to
+ // insert the assets_version setting into the database and cause a
+ // duplicate entry error.
+ if (!isset($this->config['assets_version']))
+ {
+ $this->config['assets_version'] = 0;
+ }
+
+ parent::__construct(true);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function run()
+ {
+ $this->user->session_begin();
+ $this->user->setup(array('common', 'acp/common', 'cli'));
+
+ $update_info = $this->install_config->get('update_info_unprocessed', []);
+ $version_from = !empty($update_info) ? $update_info['version']['from'] : $this->config['version_update_from'];
+
+ if (!empty($version_from))
+ {
+ $update_extensions = $this->iohandler->get_input('update-extensions', []);
+
+ // Create list of default extensions that need to be enabled in update
+ $default_update_extensions = [];
+ foreach (self::$default_extensions_update as $version => $extensions)
+ {
+ if ($this->update_helper->phpbb_version_compare($version_from, $version, '<'))
+ {
+ $default_update_extensions = array_merge($default_update_extensions, $extensions);
+ }
+ }
+
+ $all_available_extensions = $this->extension_manager->all_available();
+ $i = $this->install_config->get('update_extensions_index', 0);
+ $available_extensions = array_slice($all_available_extensions, $i);
+
+ // Update available extensions
+ foreach ($available_extensions as $ext_name => $ext_path)
+ {
+ // Update extensions if:
+ // 1) Extension is currently enabled
+ // 2) Extension was implicitly defined as needing an update
+ // 3) Extension was newly added as default phpBB extension in
+ // this update and should be enabled by default.
+ if ($this->extension_manager->is_enabled($ext_name) ||
+ in_array($ext_name, $update_extensions) ||
+ in_array($ext_name, $default_update_extensions)
+ )
+ {
+ try
+ {
+ $extension_enabled = $this->extension_manager->is_enabled($ext_name);
+ if ($extension_enabled)
+ {
+ $this->extension_manager->disable($ext_name);
+ }
+ $this->extension_manager->enable($ext_name);
+ $extensions = $this->get_extensions();
+
+ if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active'])
+ {
+ // Create log
+ $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_UPDATE', time(), array($ext_name));
+ $this->iohandler->add_success_message(array('CLI_EXTENSION_UPDATE_SUCCESS', $ext_name));
+ }
+ else
+ {
+ $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name));
+ }
+
+ // Disable extensions if it was disabled by the admin before
+ if (!$extension_enabled && !in_array($ext_name, $default_update_extensions))
+ {
+ $this->extension_manager->disable($ext_name);
+ }
+ }
+ catch (\Exception $e)
+ {
+ // Add fail log and continue
+ $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name));
+ }
+ }
+
+ $i++;
+
+ // Stop execution if resource limit is reached
+ if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
+ {
+ break;
+ }
+ }
+
+ $this->install_config->set('update_extensions_index', $i);
+
+ if ($i < sizeof($all_available_extensions))
+ {
+ throw new resource_limit_reached_exception();
+ }
+ }
+
+ $this->config->delete('version_update_from');
+
+ $this->cache->purge();
+
+ $this->config->increment('assets_version', 1);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ static public function get_step_count()
+ {
+ return 1;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_task_lang_name()
+ {
+ return 'TASK_UPDATE_EXTENSIONS';
+ }
+
+ /**
+ * Get extensions from database
+ *
+ * @return array List of extensions
+ */
+ private function get_extensions()
+ {
+ $sql = 'SELECT *
+ FROM ' . $this->extension_table;
+
+ $result = $this->db->sql_query($sql);
+ $extensions_row = $this->db->sql_fetchrowset($result);
+ $this->db->sql_freeresult($result);
+
+ $extensions = array();
+
+ foreach ($extensions_row as $extension)
+ {
+ $extensions[$extension['ext_name']] = $extension;
+ }
+
+ ksort($extensions);
+
+ return $extensions;
+ }
+}
diff --git a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php
index e3e6db6263..1792a3b723 100644
--- a/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php
+++ b/phpBB/phpbb/install/module/update_filesystem/task/diff_files.php
@@ -132,41 +132,62 @@ class diff_files extends task_base
$file_contents = array();
// Handle the special case when user created a file with the filename that is now new in the core
- $file_contents[0] = (file_exists($old_path . $filename)) ? file_get_contents($old_path . $filename) : '';
+ if (file_exists($old_path . $filename))
+ {
+ $file_contents[0] = file_get_contents($old_path . $filename);
- $filenames = array(
- $this->phpbb_root_path . $filename,
- $new_path . $filename
- );
+ $filenames = array(
+ $this->phpbb_root_path . $filename,
+ $new_path . $filename
+ );
- foreach ($filenames as $file_to_diff)
- {
- $file_contents[] = file_get_contents($file_to_diff);
+ foreach ($filenames as $file_to_diff)
+ {
+ $file_contents[] = file_get_contents($file_to_diff);
+
+ if ($file_contents[sizeof($file_contents) - 1] === false)
+ {
+ $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff));
+ unset($file_contents);
+ throw new user_interaction_required_exception();
+ }
+ }
- if ($file_contents[sizeof($file_contents) - 1] === false)
+ $diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]);
+ unset($file_contents);
+
+ // Handle conflicts
+ if ($diff->get_num_conflicts() !== 0)
{
- $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff));
- unset($file_contents);
- throw new user_interaction_required_exception();
+ $merge_conflicts[] = $filename;
}
- }
- $diff = new \diff3($file_contents[0], $file_contents[1], $file_contents[2]);
- unset($file_contents);
+ // Save merged output
+ $this->cache->put(
+ '_file_' . md5($filename),
+ base64_encode(implode("\n", $diff->merged_output()))
+ );
- // Handle conflicts
- if ($diff->get_num_conflicts() !== 0)
- {
- $merge_conflicts[] = $filename;
+ unset($diff);
}
+ else
+ {
+ $new_file_content = file_get_contents($new_path . $filename);
- // Save merged output
- $this->cache->put(
- '_file_' . md5($filename),
- base64_encode(implode("\n", $diff->merged_output()))
- );
+ if ($new_file_content === false)
+ {
+ $this->iohandler->add_error_message(array('FILE_DIFFER_ERROR_FILE_CANNOT_BE_READ', $files_to_diff));
+ unset($new_file_content );
+ throw new user_interaction_required_exception();
+ }
- unset($diff);
+ // Save new file content to cache
+ $this->cache->put(
+ '_file_' . md5($filename),
+ base64_encode($new_file_content)
+ );
+ unset($new_file_content);
+ }
$progress_count++;
$this->iohandler->set_progress('UPDATE_FILE_DIFF', $progress_count);
diff --git a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php
index f4b3870148..47a71eb844 100644
--- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php
+++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php
@@ -118,6 +118,17 @@ class file_check extends task_base
$this->iohandler->set_task_count($task_count);
$this->iohandler->set_progress('UPDATE_CHECK_FILES', 0);
+ // Create list of default extensions that should have been added prior
+ // to this update
+ $default_update_extensions = [];
+ foreach (\phpbb\install\module\update_database\task\update_extensions::$default_extensions_update as $version => $extensions)
+ {
+ if ($this->update_helper->phpbb_version_compare($update_info['version']['from'], $version, '>='))
+ {
+ $default_update_extensions = array_merge($default_update_extensions, $extensions);
+ }
+ }
+
foreach ($update_info['files'] as $key => $filename)
{
$old_file = $old_path . $filename;
@@ -138,6 +149,27 @@ class file_check extends task_base
$progress_count++;
$this->iohandler->set_progress('UPDATE_CHECK_FILES', $progress_count);
+ // Do not copy default extension again if the previous version was
+ // packaged with it but it does not exist (e.g. deleted by admin)
+ if (strpos($file, $this->phpbb_root_path . 'ext/') !== false)
+ {
+ $skip_file = false;
+ foreach ($default_update_extensions as $ext_name)
+ {
+ if (strpos($file, $this->phpbb_root_path . 'ext/' . $ext_name) !== false &&
+ !$this->filesystem->exists($this->phpbb_root_path . 'ext/' . $ext_name . '/composer.json'))
+ {
+ $skip_file = true;
+ break;
+ }
+ }
+
+ if ($skip_file)
+ {
+ continue;
+ }
+ }
+
if (!$this->filesystem->exists($file))
{
$file_update_info['new'][] = $filename;
diff --git a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php
index 7f18950cf6..cf1e4cf4ac 100644
--- a/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php
+++ b/phpBB/phpbb/install/module/update_filesystem/task/show_file_status.php
@@ -92,7 +92,7 @@ class show_file_status extends task_base
// Create archive for merge conflicts
if (!empty($merge_conflicts))
{
- $compression_method = $this->installer_config->get('compression_method', '');
+ $compression_method = $this->installer_config->get('file_update_compression', '');
$conflict_archive = $this->file_updater->init($compression_method);
$this->installer_config->set('update_file_conflict_archive', $conflict_archive);
diff --git a/phpBB/phpbb/install/updater_configuration.php b/phpBB/phpbb/install/updater_configuration.php
index e992356290..5c1c29f1da 100644
--- a/phpBB/phpbb/install/updater_configuration.php
+++ b/phpBB/phpbb/install/updater_configuration.php
@@ -32,6 +32,10 @@ class updater_configuration implements ConfigurationInterface
->addDefaultsIfNotSet()
->children()
->enumNode('type')->values(['all','db_only'])->defaultValue('all')->end()
+ ->arrayNode('extensions')
+ ->prototype('scalar')->end()
+ ->defaultValue([])
+ ->end()
->end()
;