aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php50
-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/installer.php11
-rw-r--r--phpBB/phpbb/install/installer_configuration.php4
-rw-r--r--phpBB/phpbb/install/module/install_finish/task/install_extensions.php199
-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/file_check.php32
-rw-r--r--phpBB/phpbb/install/updater_configuration.php4
10 files changed, 567 insertions, 4 deletions
diff --git a/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php
new file mode 100644
index 0000000000..afa67fbc58
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php
@@ -0,0 +1,50 @@
+<?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\db\migration\data\v320;
+
+class add_help_phpbb extends \phpbb\db\migration\migration
+{
+ static public function depends_on()
+ {
+ return array(
+ '\phpbb\db\migration\data\v320\v320rc1',
+ );
+ }
+
+ public function effectively_installed()
+ {
+ return isset($this->config['help_send_statistics']);
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.add', array('help_send_statistics', true)),
+ array('config.add', array('help_send_statistics_time', 0)),
+ array('module.remove', array(
+ 'acp',
+ false,
+ 'ACP_SEND_STATISTICS',
+ )),
+ array('module.add', array(
+ 'acp',
+ 'ACP_SERVER_CONFIGURATION',
+ array(
+ 'module_basename' => 'acp_help_phpbb',
+ 'modes' => array('help_phpbb'),
+ ),
+ )),
+ );
+ }
+}
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/installer.php b/phpBB/phpbb/install/installer.php
index 240423ae78..a7d3b99dcb 100644
--- a/phpBB/phpbb/install/installer.php
+++ b/phpBB/phpbb/install/installer.php
@@ -243,8 +243,15 @@ class installer
}
else
{
- global $SID;
- $acp_url = $this->web_root . 'adm/index.php' . $SID;
+ // Start session and try to apply session id
+ $auth = $this->container_factory->get('auth');
+ $user = $this->container_factory->get('user');
+ $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_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/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..13c1591dcd
--- /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/file_check.php b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php
index f4b3870148..5b48350e73 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/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()
;