From c30394ff4a1034e5e6e7a0862e9101b5a80d8587 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 7 Dec 2015 09:59:47 +0100 Subject: [PATCH 01/47] [ticket/14492] Add basic task for installing viglink extension PHPBB3-14492 --- .../container/services_install_finish.yml | 9 ++ phpBB/language/en/install.php | 1 + .../install_finish/task/install_viglink.php | 119 ++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 phpBB/phpbb/install/module/install_finish/task/install_viglink.php diff --git a/phpBB/config/installer/container/services_install_finish.yml b/phpBB/config/installer/container/services_install_finish.yml index 8b06ad7d97..eeddf14070 100644 --- a/phpBB/config/installer/container/services_install_finish.yml +++ b/phpBB/config/installer/container/services_install_finish.yml @@ -18,6 +18,15 @@ services: tags: - { name: install_finish, order: 20 } + installer.install_finish.install_viglink: + class: phpbb\install\module\install_finish\task\install_viglink + arguments: + - @installer.helper.container_factory + - @installer.helper.config + - @installer.helper.iohandler + tags: + - { name: install_finish, order: 15 } + installer.module.install_finish_collection: class: phpbb\di\ordered_service_collection arguments: diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 35cea17a24..73f7f400a6 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -301,6 +301,7 @@ $lang = array_merge($lang, array( 'TASK_ADD_MODULES' => 'Installing modules', // Install finish tasks + 'TASK_INSTALL_VIGLINK' => 'Installing viglink extension', 'TASK_NOTIFY_USER' => 'Sending notification e-mail', 'TASK_POPULATE_MIGRATIONS' => 'Populating migrations', diff --git a/phpBB/phpbb/install/module/install_finish/task/install_viglink.php b/phpBB/phpbb/install/module/install_finish/task/install_viglink.php new file mode 100644 index 0000000000..1facb1eaf4 --- /dev/null +++ b/phpBB/phpbb/install/module/install_finish/task/install_viglink.php @@ -0,0 +1,119 @@ + + * @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; + +/** + * Installs viglink extension with default config + */ +class install_viglink 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; + + /** + * Constructor + * + * @param \phpbb\install\helper\container_factory $container + * @param \phpbb\install\helper\config $install_config + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler + */ + public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\install\helper\config $install_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler) + { + $this->install_config = $install_config; + $this->iohandler = $iohandler; + + $this->log = $container->get('log'); + $this->user = $container->get('user'); + $this->extension_manager = $container->get('ext.manager'); + $this->config = $container->get('config'); + + // 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')); + $name = 'phpbb/viglink'; + + // Should be available by default but make sure it is + if ($this->extension_manager->is_available($name)) + { + $this->extension_manager->enable($name); + $this->extension_manager->load_extensions(); + + if (!$this->extension_manager->is_enabled($name)) + { + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name)); + } + } + else + { + $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array('phpbb/viglink')); + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 1; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_INSTALL_VIGLINK'; + } +} From 9525a64d6411cea7c72b140e8266678593148038 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 10 Dec 2015 09:32:02 +0100 Subject: [PATCH 02/47] [ticket/14492] Start working on the build script PHPBB3-14492 --- build/build.xml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/build/build.xml b/build/build.xml index 9cf222ae9e..0fdf6c0cb0 100644 --- a/build/build.xml +++ b/build/build.xml @@ -287,6 +287,28 @@ + + + + + + + + + + + + + + + + + + + + + + From 36460ebdf679f3cecb11afdc6e43e64195cc1d27 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 28 Jan 2016 20:24:51 +0100 Subject: [PATCH 03/47] [ticket/14492] Do not copy viglink on update if it was deleted PHPBB3-14492 --- .../install/module/update_filesystem/task/file_check.php | 9 +++++++++ 1 file changed, 9 insertions(+) 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..e4e0be0531 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -138,6 +138,15 @@ class file_check extends task_base $progress_count++; $this->iohandler->set_progress('UPDATE_CHECK_FILES', $progress_count); + // Do not copy viglink 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/phpbb/viglink') !== false && + $this->update_helper->phpbb_version_compare($update_info['version']['from'], '3.2.0', '>=') && + !$this->filesystem->exists($this->phpbb_root_path . 'ext/phpbb/viglink')) + { + continue; + } + if (!$this->filesystem->exists($file)) { $file_update_info['new'][] = $filename; From 8fb2347cfa89ef9768311e92f11da4b090b94f7b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 28 Jan 2016 23:13:36 +0100 Subject: [PATCH 04/47] [ticket/14492] Install all packaged extensions by default PHPBB3-14492 --- .../container/services_install_finish.yml | 21 +++++---- phpBB/language/en/install.php | 2 +- ...all_viglink.php => install_extensions.php} | 46 +++++++++++++------ 3 files changed, 43 insertions(+), 26 deletions(-) rename phpBB/phpbb/install/module/install_finish/task/{install_viglink.php => install_extensions.php} (63%) diff --git a/phpBB/config/installer/container/services_install_finish.yml b/phpBB/config/installer/container/services_install_finish.yml index eeddf14070..fbacb9b672 100644 --- a/phpBB/config/installer/container/services_install_finish.yml +++ b/phpBB/config/installer/container/services_install_finish.yml @@ -7,6 +7,16 @@ services: tags: - { name: install_finish, order: 10 } + installer.install_finish.install_viglink: + class: phpbb\install\module\install_finish\task\install_extensions + arguments: + - '@installer.helper.container_factory' + - '@installer.helper.config' + - '@installer.helper.iohandler' + - '%core.root_path%' + tags: + - { name: install_finish, order: 20 } + installer.install_finish.notify_user: class: phpbb\install\module\install_finish\task\notify_user arguments: @@ -16,16 +26,7 @@ services: - '%core.root_path%' - '%core.php_ext%' tags: - - { name: install_finish, order: 20 } - - installer.install_finish.install_viglink: - class: phpbb\install\module\install_finish\task\install_viglink - arguments: - - @installer.helper.container_factory - - @installer.helper.config - - @installer.helper.iohandler - tags: - - { name: install_finish, order: 15 } + - { name: install_finish, order: 30 } installer.module.install_finish_collection: class: phpbb\di\ordered_service_collection diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 73f7f400a6..d1bb5842df 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -301,7 +301,7 @@ $lang = array_merge($lang, array( 'TASK_ADD_MODULES' => 'Installing modules', // Install finish tasks - 'TASK_INSTALL_VIGLINK' => 'Installing viglink extension', + 'TASK_INSTALL_EXTENSIONS' => 'Installing packaged extensions', 'TASK_NOTIFY_USER' => 'Sending notification e-mail', 'TASK_POPULATE_MIGRATIONS' => 'Populating migrations', diff --git a/phpBB/phpbb/install/module/install_finish/task/install_viglink.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php similarity index 63% rename from phpBB/phpbb/install/module/install_finish/task/install_viglink.php rename to phpBB/phpbb/install/module/install_finish/task/install_extensions.php index 1facb1eaf4..6b2881aa2f 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_viglink.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -14,9 +14,9 @@ namespace phpbb\install\module\install_finish\task; /** - * Installs viglink extension with default config + * Installs extensions that exist in ext folder upon install */ -class install_viglink extends \phpbb\install\task_base +class install_extensions extends \phpbb\install\task_base { /** * @var \phpbb\install\helper\config @@ -46,14 +46,18 @@ class install_viglink extends \phpbb\install\task_base /** @var \phpbb\extension\manager */ protected $extension_manager; + /** @var \Symfony\Component\Finder\Finder */ + protected $finder; + /** * 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) + 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; @@ -62,6 +66,12 @@ class install_viglink extends \phpbb\install\task_base $this->user = $container->get('user'); $this->extension_manager = $container->get('ext.manager'); $this->config = $container->get('config'); + $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 @@ -83,21 +93,27 @@ class install_viglink extends \phpbb\install\task_base $this->user->setup(array('common', 'acp/common', 'cli')); $name = 'phpbb/viglink'; - // Should be available by default but make sure it is - if ($this->extension_manager->is_available($name)) + // Find available extensions + foreach ($this->finder as $file) { - $this->extension_manager->enable($name); - $this->extension_manager->load_extensions(); + /** @var \SplFileInfo $file */ + $ext_name = preg_replace('#(.+ext[\\/\\\])#', '', dirname($file->getRealPath())); - if (!$this->extension_manager->is_enabled($name)) + if ($this->extension_manager->is_available($ext_name)) { - // Create log - $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name)); + $this->extension_manager->enable($ext_name); + $this->extension_manager->load_extensions(); + + if (!$this->extension_manager->is_enabled($ext_name)) + { + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); + } + } + else + { + $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); } - } - else - { - $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array('phpbb/viglink')); } } @@ -114,6 +130,6 @@ class install_viglink extends \phpbb\install\task_base */ public function get_task_lang_name() { - return 'TASK_INSTALL_VIGLINK'; + return 'TASK_INSTALL_EXTENSIONS'; } } From 267d1b15c4884dd67a299b2428251e68cd55327b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 29 Jan 2016 10:13:06 +0100 Subject: [PATCH 05/47] [ticket/14492] Re-enable extensions if updated during update PHPBB3-14492 --- .../container/services_install_finish.yml | 4 +- .../container/services_update_database.yml | 13 +- phpBB/language/en/install.php | 2 + .../task/install_extensions.php | 3 +- .../task/update_extensions.php | 162 ++++++++++++++++++ 5 files changed, 179 insertions(+), 5 deletions(-) create mode 100644 phpBB/phpbb/install/module/update_database/task/update_extensions.php diff --git a/phpBB/config/installer/container/services_install_finish.yml b/phpBB/config/installer/container/services_install_finish.yml index fbacb9b672..7537d86727 100644 --- a/phpBB/config/installer/container/services_install_finish.yml +++ b/phpBB/config/installer/container/services_install_finish.yml @@ -7,7 +7,7 @@ services: tags: - { name: install_finish, order: 10 } - installer.install_finish.install_viglink: + installer.install_finish.install_extensions: class: phpbb\install\module\install_finish\task\install_extensions arguments: - '@installer.helper.container_factory' @@ -41,4 +41,4 @@ services: arguments: - '@installer.module.install_finish_collection' tags: - - { name: installer_install_module, order: 60 } + - { name: installer_install_module, order: 80 } diff --git a/phpBB/config/installer/container/services_update_database.yml b/phpBB/config/installer/container/services_update_database.yml index 9cb9cb9abf..aabfceca58 100644 --- a/phpBB/config/installer/container/services_update_database.yml +++ b/phpBB/config/installer/container/services_update_database.yml @@ -11,6 +11,17 @@ services: tags: - { name: update_database_task, order: 10 } + installer.update_database.update_extensions: + class: phpbb\install\module\update_database\task\update_extensions + arguments: + - '@installer.helper.container_factory' + - '@installer.helper.config' + - '@installer.helper.iohandler' + - '@installer.helper.update_helper' + - '%core.root_path%' + tags: + - { name: update_database_task, order: 20 } + installer.module.update_database_collection: class: phpbb\di\ordered_service_collection arguments: @@ -26,4 +37,4 @@ services: - true - false tags: - - { name: installer_update_module, order: 40 } + - { name: installer_update_module, order: 60 } diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index d1bb5842df..45ed51f641 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -458,6 +458,8 @@ $lang = array_merge($lang, array( 'STAGE_UPDATE_DATABASE' => 'Update database', 'INLINE_UPDATE_SUCCESSFUL' => 'The database update was successful.', + + 'TASK_UPDATE_EXTENSIONS' => 'Updating extensions', )); // Converter diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index 6b2881aa2f..28911b36c5 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -91,7 +91,6 @@ class install_extensions extends \phpbb\install\task_base { $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); - $name = 'phpbb/viglink'; // Find available extensions foreach ($this->finder as $file) @@ -122,7 +121,7 @@ class install_extensions extends \phpbb\install\task_base */ static public function get_step_count() { - return 1; + return 0; } /** 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..c7437d4746 --- /dev/null +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -0,0 +1,162 @@ + + * @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\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 enable_extensions extends task_base +{ + /** + * @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; + + /** + * 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->log = $container->get('log'); + $this->user = $container->get('user'); + $this->extension_manager = $container->get('ext.manager'); + $this->config = $container->get('config'); + $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', array()); + + if (!empty($update_info)) + { + // Find available extensions + foreach ($this->finder as $file) + { + /** @var \SplFileInfo $file */ + $ext_name = preg_replace('#(.+ext[\\/\\\])#', '', dirname($file->getRealPath())); + + // Skip extensions that were not added or updated during update + if (!count(preg_grep('#ext/' . $ext_name . '#', $update_info['files']))) + { + continue; + } + + // Disable enabled extensions in order to run migrations if needed + if ($this->extension_manager->is_enabled($ext_name)) + { + $this->extension_manager->disable($ext_name); + } + + if ($this->extension_manager->is_available($ext_name)) + { + $this->extension_manager->enable($ext_name); + $this->extension_manager->load_extensions(); + + if (!$this->extension_manager->is_enabled($ext_name)) + { + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); + } + } + else + { + $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + } + } + } + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return 'TASK_UPDATE_EXTENSIONS'; + } +} From c5e0635bc79197011744394a221b5ccdcf305fc6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 30 Jan 2016 12:21:30 +0100 Subject: [PATCH 06/47] [ticket/14492] Add basic layout for enabling viglink PHPBB3-14492 --- phpBB/adm/style/acp_send_statistics.html | 18 ++++++- phpBB/adm/style/admin.css | 61 ++++++++++++++++++++++++ phpBB/adm/style/overall_header.html | 1 + phpBB/includes/functions_acp.php | 1 + phpBB/language/en/acp/common.php | 1 + 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/phpBB/adm/style/acp_send_statistics.html b/phpBB/adm/style/acp_send_statistics.html index 480e438e1f..d1f695bf8e 100644 --- a/phpBB/adm/style/acp_send_statistics.html +++ b/phpBB/adm/style/acp_send_statistics.html @@ -4,8 +4,21 @@

{L_SEND_STATISTICS}

-

{L_EXPLAIN_SEND_STATISTICS}

- +
+
+
+

Send statistics

+

{L_EXPLAIN_SEND_STATISTICS}

+
+
+
+
+

+

{L_EXPLAIN_ENABLE_VIGLINK}

+
+
+
+
- - -
- -

{L_DONT_SEND_STATISTICS}

- -

{L_EXPLAIN_SHOW_STATISTICS}

- -

- -
- -

- -

- - -
- {providers.NAME} - -
-
{providers.values.KEY}
-
{providers.values.VALUE}
-
- -
- -
-

- - -

-
- -
-

{L_THANKS_SEND_STATISTICS}

« {L_GO_ACP_MAIN}

-
diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index c791f30cbc..afa0bd5d31 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -2585,12 +2585,7 @@ fieldset.permissions .padding { } .send-stats-row { - margin: 25px -15px 0; -} - -.send-stats-row h3 { - margin: 0; - text-align: center; + margin: 15px 0; } .send-stats-row:before { @@ -2598,20 +2593,6 @@ fieldset.permissions .padding { content: " "; } -.send-stats-col { - width: 50%; - float: left; - position: relative; - min-height: 1px; - padding-right: 15px; - padding-left: 15px; - box-sizing: border-box; -} - -.send-stats-row > .send-stats-col:last-child { - padding-left: 0; -} - .send-stats-tile { position: relative; padding: 14px; @@ -2624,10 +2605,7 @@ fieldset.permissions .padding { .send-stats-tile h2 { margin-top: 0; text-align: center; -} - -.send-stats-tile h2 > p { - display: inline-block; + padding-bottom: 1em; } .send-stats-tile i { @@ -2644,3 +2622,77 @@ fieldset.permissions .padding { font-family: FontAwesome; font-style: normal; } + +.send-stats-data-row { + background: #f9f9f9; + border-radius: 6px; + border: #DEDEDE 1px solid; + padding: 10px; + border-top-width: 0; + border-top-right-radius: 0; + border-top-left-radius: 0; +} + +.send-stats-data-hidden .configlist { + display: none; +} + +.send-stats-data-only-row { + border-radius: 6px !important; + border-bottom-width: 1px !important; +} + +.send-stats-data-hidden { + padding: 0; + border: none; +} + +.send-stats-row > .send-stats-data-row:first-child { + background-color: #d9edf7; + border-bottom-width: 0; + border-top-right-radius: 6px; + border-top-left-radius: 6px; + border-top-width: 1px; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +.send-stats-settings dt, .send-stats-settings dd { + min-width: 25px; +} + +.send-stats-settings dd { + line-height: 1.5em; +} + +.send-stats-settings input { + display: none; +} + +.send-stats-settings input[type=checkbox] + label:before { + content: "\f096"; + font-family: FontAwesome; + font-size: 1.5em; +} + +.send-stats-settings input[type=checkbox]:checked + label:before { + content: "\f14a"; + color: #3c763d; +} + +.send-stats-data-row a:hover span { + text-decoration: underline; +} + +.send-stats-data-row a { + text-decoration: none; +} + +.send-stats-data-row i { + padding-left: 6px; +} + +.configlist { + word-wrap: break-word; + word-break: break-all; +} diff --git a/phpBB/adm/style/admin.js b/phpBB/adm/style/admin.js index 253fd46a62..e42fdb380a 100644 --- a/phpBB/adm/style/admin.js +++ b/phpBB/adm/style/admin.js @@ -243,8 +243,11 @@ function parse_document(container) parse_document($('body')); - // Hide configlist and success message in send statistics page - phpbb.toggleDisplay('configlist', -1); - phpbb.toggleDisplay('questionnaire-thanks', -1); + $('#trigger-configlist').on('click', function () { + var $configlist = $('#configlist'); + $configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden'); + $configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row'); + $(this).find('i').toggleClass('fa-angle-down fa-angle-up'); + }); }); })(jQuery); From c1035c98e455548fe14fbf5443bb98137d4e3d5d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 31 Jan 2016 23:49:17 +0100 Subject: [PATCH 09/47] [ticket/14492] Rename files to help_phpbb and fix css tabbing PHPBB3-14492 --- ...nd_statistics.html => acp_help_phpbb.html} | 23 +------ phpBB/adm/style/admin.css | 61 ++++++++++--------- ...send_statistics.php => acp_help_phpbb.php} | 4 +- ...send_statistics.php => acp_help_phpbb.php} | 6 +- .../db/migration/data/v320/add_help_phpbb.php | 49 +++++++++++++++ 5 files changed, 87 insertions(+), 56 deletions(-) rename phpBB/adm/style/{acp_send_statistics.html => acp_help_phpbb.html} (78%) rename phpBB/includes/acp/{acp_send_statistics.php => acp_help_phpbb.php} (96%) rename phpBB/includes/acp/info/{acp_send_statistics.php => acp_help_phpbb.php} (68%) create mode 100644 phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php diff --git a/phpBB/adm/style/acp_send_statistics.html b/phpBB/adm/style/acp_help_phpbb.html similarity index 78% rename from phpBB/adm/style/acp_send_statistics.html rename to phpBB/adm/style/acp_help_phpbb.html index b45886f943..a984b25b25 100644 --- a/phpBB/adm/style/acp_send_statistics.html +++ b/phpBB/adm/style/acp_help_phpbb.html @@ -30,10 +30,10 @@
- +
-
{L_YES}
+
{L_SEND_STATISTICS}
@@ -48,24 +48,5 @@
-
- - -
diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index afa0bd5d31..d4df01dba7 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -2624,72 +2624,73 @@ fieldset.permissions .padding { } .send-stats-data-row { - background: #f9f9f9; - border-radius: 6px; - border: #DEDEDE 1px solid; - padding: 10px; - border-top-width: 0; - border-top-right-radius: 0; - border-top-left-radius: 0; + background: #f9f9f9; + border-radius: 6px; + border: #DEDEDE 1px solid; + padding: 10px; + border-top-width: 0; + border-top-right-radius: 0; + border-top-left-radius: 0; } .send-stats-data-hidden .configlist { - display: none; + display: none; } .send-stats-data-only-row { - border-radius: 6px !important; - border-bottom-width: 1px !important; + border-radius: 6px !important; + border-bottom-width: 1px !important; } .send-stats-data-hidden { - padding: 0; - border: none; + padding: 0; + border: none; } .send-stats-row > .send-stats-data-row:first-child { - background-color: #d9edf7; - border-bottom-width: 0; - border-top-right-radius: 6px; - border-top-left-radius: 6px; - border-top-width: 1px; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; + background-color: #d9edf7; + border-bottom-width: 0; + border-top-right-radius: 6px; + border-top-left-radius: 6px; + border-top-width: 1px; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; } .send-stats-settings dt, .send-stats-settings dd { - min-width: 25px; + min-width: 25px; } .send-stats-settings dd { - line-height: 1.5em; + line-height: 1.5em; } .send-stats-settings input { - display: none; + display: none; } .send-stats-settings input[type=checkbox] + label:before { - content: "\f096"; - font-family: FontAwesome; - font-size: 1.5em; + content: "\f096"; + font-family: FontAwesome; + font-size: 1.5em; } .send-stats-settings input[type=checkbox]:checked + label:before { - content: "\f14a"; - color: #3c763d; + content: "\f14a"; + color: #3c763d; } .send-stats-data-row a:hover span { - text-decoration: underline; + text-decoration: underline; } .send-stats-data-row a { - text-decoration: none; + text-decoration: none; + cursor: default; } .send-stats-data-row i { - padding-left: 6px; + padding-left: 6px; } .configlist { diff --git a/phpBB/includes/acp/acp_send_statistics.php b/phpBB/includes/acp/acp_help_phpbb.php similarity index 96% rename from phpBB/includes/acp/acp_send_statistics.php rename to phpBB/includes/acp/acp_help_phpbb.php index 74da5996f1..cfe9619898 100644 --- a/phpBB/includes/acp/acp_send_statistics.php +++ b/phpBB/includes/acp/acp_help_phpbb.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) exit; } -class acp_send_statistics +class acp_help_phpbb { var $u_action; @@ -34,7 +34,7 @@ class acp_send_statistics $collect_url = "https://www.phpbb.com/stats/receive_stats.php"; - $this->tpl_name = 'acp_send_statistics'; + $this->tpl_name = 'acp_help_phpbb'; $this->page_title = 'ACP_SEND_STATISTICS'; // generate a unique id if necessary diff --git a/phpBB/includes/acp/info/acp_send_statistics.php b/phpBB/includes/acp/info/acp_help_phpbb.php similarity index 68% rename from phpBB/includes/acp/info/acp_send_statistics.php rename to phpBB/includes/acp/info/acp_help_phpbb.php index a0db1a48c4..17a07ec4f6 100644 --- a/phpBB/includes/acp/info/acp_send_statistics.php +++ b/phpBB/includes/acp/info/acp_help_phpbb.php @@ -11,15 +11,15 @@ * */ -class acp_send_statistics_info +class acp_help_phpbb_info { function module() { return array( - 'filename' => 'acp_send_statistics', + 'filename' => 'acp_help_phpbb', 'title' => 'ACP_SEND_STATISTICS', 'modes' => array( - 'send_statistics' => array('title' => 'ACP_SEND_STATISTICS', 'auth' => 'acl_a_server', 'cat' => array('ACP_SERVER_CONFIGURATION')), + 'help_phpbb' => array('title' => 'ACP_SEND_STATISTICS', 'auth' => 'acl_a_server', 'cat' => array('ACP_SERVER_CONFIGURATION')), ), ); } 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..4274f53520 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php @@ -0,0 +1,49 @@ + +* @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\v320a2', + ); + } + + 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('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'), + ), + )), + ); + } +} From 9fb2a5d5f8ed4c23689843178a4a06a151d146e6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 1 Feb 2016 00:01:26 +0100 Subject: [PATCH 10/47] [ticket/14492] Update language variables and trigger details text PHPBB3-14492 --- phpBB/adm/style/acp_help_phpbb.html | 6 +++--- phpBB/includes/acp/acp_help_phpbb.php | 2 +- phpBB/includes/acp/info/acp_help_phpbb.php | 4 ++-- phpBB/language/en/acp/common.php | 8 +++++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/phpBB/adm/style/acp_help_phpbb.html b/phpBB/adm/style/acp_help_phpbb.html index a984b25b25..347d39af86 100644 --- a/phpBB/adm/style/acp_help_phpbb.html +++ b/phpBB/adm/style/acp_help_phpbb.html @@ -2,7 +2,7 @@ -

{L_SEND_STATISTICS}

+

{L_ACP_HELP_PHPBB}

@@ -10,7 +10,7 @@

{L_EXPLAIN_SEND_STATISTICS}

@@ -33,7 +33,7 @@ -
{L_SEND_STATISTICS}
+
{L_SEND_STATISTICS_LONG}
diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php index cfe9619898..2ac90eee48 100644 --- a/phpBB/includes/acp/acp_help_phpbb.php +++ b/phpBB/includes/acp/acp_help_phpbb.php @@ -35,7 +35,7 @@ class acp_help_phpbb $collect_url = "https://www.phpbb.com/stats/receive_stats.php"; $this->tpl_name = 'acp_help_phpbb'; - $this->page_title = 'ACP_SEND_STATISTICS'; + $this->page_title = 'ACP_HELP_PHPBB'; // generate a unique id if necessary if (!isset($config['questionnaire_unique_id'])) diff --git a/phpBB/includes/acp/info/acp_help_phpbb.php b/phpBB/includes/acp/info/acp_help_phpbb.php index 17a07ec4f6..dee8ef41d7 100644 --- a/phpBB/includes/acp/info/acp_help_phpbb.php +++ b/phpBB/includes/acp/info/acp_help_phpbb.php @@ -17,9 +17,9 @@ class acp_help_phpbb_info { return array( 'filename' => 'acp_help_phpbb', - 'title' => 'ACP_SEND_STATISTICS', + 'title' => 'ACP_HELP_PHPBB', 'modes' => array( - 'help_phpbb' => array('title' => 'ACP_SEND_STATISTICS', 'auth' => 'acl_a_server', 'cat' => array('ACP_SERVER_CONFIGURATION')), + 'help_phpbb' => array('title' => 'ACP_HELP_PHPBB', 'auth' => 'acl_a_server', 'cat' => array('ACP_SERVER_CONFIGURATION')), ), ); } diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 0acc18e373..a233547c7e 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -108,6 +108,8 @@ $lang = array_merge($lang, array( 'ACP_GROUPS_PERMISSIONS' => 'Group permissions', 'ACP_GROUPS_POSITION' => 'Manage group positions', + 'ACP_HELP_PHPBB' => 'Help support phpBB', + 'ACP_ICONS' => 'Topic icons', 'ACP_ICONS_SMILIES' => 'Topic icons/smilies', 'ACP_INACTIVE_USERS' => 'Inactive users', @@ -167,7 +169,6 @@ $lang = array_merge($lang, array( 'ACP_SEARCH_SETTINGS' => 'Search settings', 'ACP_SECURITY_SETTINGS' => 'Security settings', - 'ACP_SEND_STATISTICS' => 'Send statistical information', 'ACP_SERVER_CONFIGURATION' => 'Server configuration', 'ACP_SERVER_SETTINGS' => 'Server settings', 'ACP_SIGNATURE_SETTINGS' => 'Signature settings', @@ -474,14 +475,15 @@ $lang = array_merge($lang, array( 'USER_IS_INACTIVE' => 'User is inactive', )); -// Send statistics page +// Help support phpBB page $lang = array_merge($lang, array( 'EXPLAIN_SEND_STATISTICS' => 'Please send information about your server and board configurations to phpBB for statistical analysis. All information that could identify you or your website has been removed - the data is entirely anonymous. We base decisions about future phpBB versions on this information. The statistics are made available publically. We also share this data with the PHP project, the programming language phpBB is made with.', 'EXPLAIN_SHOW_STATISTICS' => 'Using the button below you can preview all variables that will be transmitted.', 'DONT_SEND_STATISTICS' => 'Return to the ACP if you do not wish to send statistical information to phpBB.', 'GO_ACP_MAIN' => 'Go to the ACP start page', 'HIDE_STATISTICS' => 'Hide details', - 'SEND_STATISTICS' => 'Send statistical information', + 'SEND_STATISTICS' => 'Send statistics', + 'SEND_STATISTICS_LONG' => 'Send statistical information', 'SHOW_STATISTICS' => 'Show details', 'THANKS_SEND_STATISTICS' => 'Thank you for submitting your information.', 'EXPLAIN_ENABLE_VIGLINK' => 'Viglink is a non-invasive third-party service that will monetize existing links posted by users of your forum. When visitors click on those existing links and perform certain actions, such as shopping, the merchants pay VigLink a commission, of which a share is donated to the phpBB project. By agreeing to enable VigLink and donating proceeds to the phpBB project, you are supporting our open source organization and ensuring our continued financial security.

You can change these settings at any time in VigLink settings panel.', From cc7a0aa4fb2d6c8efd5c78df7d68328c9f8d4d32 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 1 Feb 2016 13:55:36 +0100 Subject: [PATCH 11/47] [ticket/14492] Use guzzle for submitting data to stats service PHPBB3-14492 --- phpBB/adm/style/acp_help_phpbb.html | 8 +++++ phpBB/includes/acp/acp_help_phpbb.php | 43 ++++++++++++++++++++++++++- phpBB/language/en/acp/common.php | 1 + 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/phpBB/adm/style/acp_help_phpbb.html b/phpBB/adm/style/acp_help_phpbb.html index 347d39af86..cbbe42e8c7 100644 --- a/phpBB/adm/style/acp_help_phpbb.html +++ b/phpBB/adm/style/acp_help_phpbb.html @@ -4,6 +4,7 @@

{L_ACP_HELP_PHPBB}

+

Send statistics

@@ -47,6 +48,13 @@
Enable
+
+

+ +

+ {S_FORM_TOKEN} +
+
diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php index 2ac90eee48..c981cf79df 100644 --- a/phpBB/includes/acp/acp_help_phpbb.php +++ b/phpBB/includes/acp/acp_help_phpbb.php @@ -25,7 +25,7 @@ class acp_help_phpbb function main($id, $mode) { - global $config, $template, $phpbb_admin_path, $phpbb_root_path, $phpEx; + global $config, $request, $template, $user, $phpbb_admin_path, $phpbb_root_path, $phpEx; if (!class_exists('phpbb_questionnaire_data_collector')) { @@ -37,6 +37,22 @@ class acp_help_phpbb $this->tpl_name = 'acp_help_phpbb'; $this->page_title = 'ACP_HELP_PHPBB'; + $submit = ($request->is_set_post('submit')) ? true : false; + + $form_key = 'acp_help_phpbb'; + add_form_key($form_key); + $error = array(); + + if ($submit && !check_form_key($form_key)) + { + $error[] = $user->lang['FORM_INVALID']; + } + // Do not write values if there is an error + if (sizeof($error)) + { + $submit = false; + } + // generate a unique id if necessary if (!isset($config['questionnaire_unique_id'])) { @@ -55,6 +71,31 @@ class acp_help_phpbb $collector->add_data_provider(new phpbb_questionnaire_system_data_provider()); $collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config)); + if ($submit) + { + $client = new \Guzzle\Http\Client( + $this->u_action, + array( + 'timeout' => 6, + 'connect_timeout' => 6, + ) + ); + + $collect_request = $client->post($collect_url, [], [ + 'systemdata' => $collector->get_data_for_form(), + ]); + + $response = $collect_request->send(); + if ($response->isSuccessful()) + { + trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action)); + } + else + { + trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action)); + } + } + $template->assign_vars(array( 'U_COLLECT_STATS' => $collect_url, 'RAW_DATA' => $collector->get_data_for_form(), diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index a233547c7e..592021624b 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -486,6 +486,7 @@ $lang = array_merge($lang, array( 'SEND_STATISTICS_LONG' => 'Send statistical information', 'SHOW_STATISTICS' => 'Show details', 'THANKS_SEND_STATISTICS' => 'Thank you for submitting your information.', + 'FAIL_SEND_STATISTICS' => 'phpBB was unable to send statistics', 'EXPLAIN_ENABLE_VIGLINK' => 'Viglink is a non-invasive third-party service that will monetize existing links posted by users of your forum. When visitors click on those existing links and perform certain actions, such as shopping, the merchants pay VigLink a commission, of which a share is donated to the phpBB project. By agreeing to enable VigLink and donating proceeds to the phpBB project, you are supporting our open source organization and ensuring our continued financial security.

You can change these settings at any time in VigLink settings panel.', )); From c07ecb060dd04c76d8bd166a0a8a7226a8167f06 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 2 Feb 2016 12:19:55 +0100 Subject: [PATCH 12/47] [ticket/14492] Add events for modifying help phpBB page PHPBB3-14492 --- phpBB/adm/style/acp_help_phpbb.html | 17 ++------- phpBB/adm/style/admin.css | 6 --- phpBB/docs/events.md | 12 ++++++ phpBB/includes/acp/acp_help_phpbb.php | 54 +++++++++++++++++---------- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/phpBB/adm/style/acp_help_phpbb.html b/phpBB/adm/style/acp_help_phpbb.html index cbbe42e8c7..a9406e2c2e 100644 --- a/phpBB/adm/style/acp_help_phpbb.html +++ b/phpBB/adm/style/acp_help_phpbb.html @@ -6,6 +6,7 @@
+

Send statistics

{L_EXPLAIN_SEND_STATISTICS}

@@ -31,23 +32,13 @@
- - + checked="checked" /> +
{L_SEND_STATISTICS_LONG}
-
-

VigLink

-

{L_EXPLAIN_ENABLE_VIGLINK}

-
-
- - -
-
Enable
-
-
+

diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index d4df01dba7..bcf01fe597 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -2612,12 +2612,6 @@ fieldset.permissions .padding { padding-right: 0.3em; } -.viglink-header { - background: url('http://www.viglink.com/wp-content/uploads/2015/05/favicon-96x96.png') no-repeat 0 0; - padding-left: 30px; - background-size: 25px; -} - .icon { font-family: FontAwesome; font-style: normal; diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index a939c6ff7e..caaff7cb0e 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -196,6 +196,18 @@ acp_groups_position_teampage_add_button_before * Since: 3.1.7-RC1 * Purpose: Add content before adding group to teampage submit button +acp_help_phpbb_stats_after +=== +* Location: adm/style/acp_help_phpbb.html +* Since: 3.2.0-b2 +* Purpose: Add content after send statistics tile + +acp_help_phpbb_stats_before +=== +* Location: adm/style/acp_help_phpbb.html +* Since: 3.2.0-b2 +* Purpose: Add content before send statistics tile + acp_logs_quick_select_forum_button_append === * Location: adm/style/acp_logs.html diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php index c981cf79df..9dd641dfd5 100644 --- a/phpBB/includes/acp/acp_help_phpbb.php +++ b/phpBB/includes/acp/acp_help_phpbb.php @@ -25,7 +25,7 @@ class acp_help_phpbb function main($id, $mode) { - global $config, $request, $template, $user, $phpbb_admin_path, $phpbb_root_path, $phpEx; + global $config, $request, $template, $user, $phpbb_dispatcher, $phpbb_admin_path, $phpbb_root_path, $phpEx; if (!class_exists('phpbb_questionnaire_data_collector')) { @@ -71,33 +71,49 @@ class acp_help_phpbb $collector->add_data_provider(new phpbb_questionnaire_system_data_provider()); $collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config)); + /** + * Event to add and/or modify acp_board configurations + * + * @event core.acp_help_phpbb_submit_before + * @var boolean submit Do we display the form or process the submission + * @since 3.2.0-b2 + */ + $vars = array('submit'); + extract($phpbb_dispatcher->trigger_event('core.acp_help_phpbb_submit_before', compact($vars))); + if ($submit) { - $client = new \Guzzle\Http\Client( - $this->u_action, - array( - 'timeout' => 6, - 'connect_timeout' => 6, - ) - ); + $config->set('help_send_statistics', $request->variable('help_send_statistics', false)); - $collect_request = $client->post($collect_url, [], [ - 'systemdata' => $collector->get_data_for_form(), - ]); + if ($config['help_send_statistics']) + { + $client = new \Guzzle\Http\Client( + $this->u_action, + array( + 'timeout' => 6, + 'connect_timeout' => 6, + ) + ); - $response = $collect_request->send(); - if ($response->isSuccessful()) - { - trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action)); - } - else - { - trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action)); + $collect_request = $client->post($collect_url, [], [ + 'systemdata' => $collector->get_data_for_form(), + ]); + + $response = $collect_request->send(); + if ($response->isSuccessful()) + { + trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action)); + } + else + { + trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action)); + } } } $template->assign_vars(array( 'U_COLLECT_STATS' => $collect_url, + 'S_COLLECT_STATS' => (!empty($config['help_send_statistics'])) ? true : false, 'RAW_DATA' => $collector->get_data_for_form(), 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"), )); From 90a5e22eb51fa20c94d576ffc5cdb49fb31dab3a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 4 Feb 2016 09:45:32 +0100 Subject: [PATCH 13/47] [ticket/14492] Correctly check if extension was enabled during install Also fixed some incorrectly generated log messages and improved the regex. PHPBB3-14492 --- .../task/install_extensions.php | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index d5086e7b82..c9a35a309a 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -49,6 +49,12 @@ class install_extensions extends \phpbb\install\task_base /** @var \Symfony\Component\Finder\Finder */ protected $finder; + /** @var string Extension table */ + protected $extension_table; + + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + /** * Constructor * @@ -61,11 +67,13 @@ class install_extensions extends \phpbb\install\task_base { $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() @@ -101,14 +109,14 @@ class install_extensions extends \phpbb\install\task_base foreach ($this->finder as $file) { /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+ext[\\/\\\])#', '', dirname($file->getRealPath())); + $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])([^\\/\\\]+)[\\/\\\]([^\\/\\\]+)#', '$2/$3', dirname($file->getRealPath())); if ($this->extension_manager->is_available($ext_name)) { $this->extension_manager->enable($ext_name); - $this->extension_manager->load_extensions(); + $extensions = $this->get_extensions(); - if (!$this->extension_manager->is_enabled($ext_name)) + if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); @@ -116,7 +124,7 @@ class install_extensions extends \phpbb\install\task_base } else { - $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); } } } @@ -136,4 +144,30 @@ class install_extensions extends \phpbb\install\task_base { 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; + } } From ade5183ba1f10e3ba1aea927204e25f3b218ceb2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 4 Feb 2016 11:20:59 +0100 Subject: [PATCH 14/47] [ticket/14492] Pass u_action to acp form and add stats config PHPBB3-14492 --- phpBB/includes/acp/acp_help_phpbb.php | 1 + phpBB/install/schemas/schema_data.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php index 9dd641dfd5..bcbe61adb8 100644 --- a/phpBB/includes/acp/acp_help_phpbb.php +++ b/phpBB/includes/acp/acp_help_phpbb.php @@ -116,6 +116,7 @@ class acp_help_phpbb 'S_COLLECT_STATS' => (!empty($config['help_send_statistics'])) ? true : false, 'RAW_DATA' => $collector->get_data_for_form(), 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"), + 'U_ACTION' => $this->u_action, )); $raw = $collector->get_data_raw(); diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 0cff26977e..450d2d2a52 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -142,6 +142,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_postgres_ INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_sphinx_indexer_mem_limit', '512'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_sphinx_stopwords', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('gzip_compress', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('help_send_statistics', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('hot_threshold', '25'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('icons_path', 'images/icons'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_create_thumbnail', '0'); From 4451db9f225d7a0e8a12503f0ff2f1393ee42467 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 4 Feb 2016 11:43:29 +0100 Subject: [PATCH 15/47] [ticket/14492] Apply fixes to update extensions task The regex was also simplified. PHPBB3-14492 --- .../task/install_extensions.php | 2 +- .../task/update_extensions.php | 40 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index c9a35a309a..d92f420202 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -109,7 +109,7 @@ class install_extensions extends \phpbb\install\task_base foreach ($this->finder as $file) { /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])([^\\/\\\]+)[\\/\\\]([^\\/\\\]+)#', '$2/$3', dirname($file->getRealPath())); + $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); if ($this->extension_manager->is_available($ext_name)) { diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index c7437d4746..a6648084a6 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -59,6 +59,12 @@ class enable_extensions extends task_base /** @var Finder */ protected $finder; + /** @var string Extension table */ + protected $extension_table; + + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + /** * Constructor * @@ -72,11 +78,13 @@ class enable_extensions extends task_base { $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 Finder(); $this->finder->in($phpbb_root_path . 'ext/') ->ignoreUnreadableDirs() @@ -111,7 +119,7 @@ class enable_extensions extends task_base foreach ($this->finder as $file) { /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+ext[\\/\\\])#', '', dirname($file->getRealPath())); + $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); // Skip extensions that were not added or updated during update if (!count(preg_grep('#ext/' . $ext_name . '#', $update_info['files']))) @@ -128,9 +136,9 @@ class enable_extensions extends task_base if ($this->extension_manager->is_available($ext_name)) { $this->extension_manager->enable($ext_name); - $this->extension_manager->load_extensions(); + $extensions = $this->get_extensions(); - if (!$this->extension_manager->is_enabled($ext_name)) + if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); @@ -159,4 +167,30 @@ class enable_extensions extends task_base { 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; + } } From cba4f4f568028d2eb019ddde0eded62799e1b377 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 12 Feb 2016 12:28:21 +0100 Subject: [PATCH 16/47] [ticket/14492] Use new guzzlehttp client PHPBB3-14492 --- phpBB/includes/acp/acp_help_phpbb.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php index bcbe61adb8..fa4de60456 100644 --- a/phpBB/includes/acp/acp_help_phpbb.php +++ b/phpBB/includes/acp/acp_help_phpbb.php @@ -87,20 +87,19 @@ class acp_help_phpbb if ($config['help_send_statistics']) { - $client = new \Guzzle\Http\Client( - $this->u_action, - array( + $client = new \GuzzleHttp\Client([ 'timeout' => 6, 'connect_timeout' => 6, - ) - ); - - $collect_request = $client->post($collect_url, [], [ - 'systemdata' => $collector->get_data_for_form(), ]); - $response = $collect_request->send(); - if ($response->isSuccessful()) + $response = $client->post($collect_url, [ + 'body' => [ + 'systemdata' => $collector->get_data_for_form(), + ] + ]); + $response_status = $response->getStatusCode(); + + if ($response_status >= 200 && $response_status < 300) { trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action)); } From f9b46a4ae7d106cb765a762acf2e6a362e5b636d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 19 Feb 2016 21:28:52 +0100 Subject: [PATCH 17/47] [ticket/14492] Remove not needed language entry PHPBB3-14492 --- phpBB/language/en/acp/common.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 592021624b..5b747acd55 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -487,7 +487,6 @@ $lang = array_merge($lang, array( 'SHOW_STATISTICS' => 'Show details', 'THANKS_SEND_STATISTICS' => 'Thank you for submitting your information.', 'FAIL_SEND_STATISTICS' => 'phpBB was unable to send statistics', - 'EXPLAIN_ENABLE_VIGLINK' => 'Viglink is a non-invasive third-party service that will monetize existing links posted by users of your forum. When visitors click on those existing links and perform certain actions, such as shopping, the merchants pay VigLink a commission, of which a share is donated to the phpBB project. By agreeing to enable VigLink and donating proceeds to the phpBB project, you are supporting our open source organization and ensuring our continued financial security.

You can change these settings at any time in VigLink settings panel.', )); // Log Entries From 80a63a9a94af042da37227ed747eba0feeac1049 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 20 Feb 2016 11:58:36 +0100 Subject: [PATCH 18/47] [ticket/14492] Add missing input name PHPBB3-14492 --- phpBB/adm/style/acp_help_phpbb.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/adm/style/acp_help_phpbb.html b/phpBB/adm/style/acp_help_phpbb.html index a9406e2c2e..d2f5e76916 100644 --- a/phpBB/adm/style/acp_help_phpbb.html +++ b/phpBB/adm/style/acp_help_phpbb.html @@ -32,7 +32,7 @@

- checked="checked" /> + checked="checked" />
{L_SEND_STATISTICS_LONG}
From 89fef2ce13a183c7b963032274f455a09a05f325 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 21 Feb 2016 22:14:58 +0100 Subject: [PATCH 19/47] [ticket/14492] Send statistics via ajax request Flooding ajax requests will try to be prevented and sending stats without JS will also properly work. PHPBB3-14492 --- phpBB/adm/style/acp_help_phpbb.html | 16 ++- phpBB/adm/style/admin.js | 7 +- phpBB/adm/style/ajax.js | 99 +++++++++++++++++++ phpBB/includes/acp/acp_help_phpbb.php | 36 ++++--- .../db/migration/data/v320/add_help_phpbb.php | 1 + 5 files changed, 136 insertions(+), 23 deletions(-) diff --git a/phpBB/adm/style/acp_help_phpbb.html b/phpBB/adm/style/acp_help_phpbb.html index d2f5e76916..48a4595913 100644 --- a/phpBB/adm/style/acp_help_phpbb.html +++ b/phpBB/adm/style/acp_help_phpbb.html @@ -4,7 +4,7 @@

{L_ACP_HELP_PHPBB}

- +
@@ -12,9 +12,9 @@

{L_EXPLAIN_SEND_STATISTICS}

-
+
@@ -41,11 +41,21 @@

+ +

{S_FORM_TOKEN}
+
+
+

+ + +

+
+
diff --git a/phpBB/adm/style/admin.js b/phpBB/adm/style/admin.js index e42fdb380a..551c78a4a3 100644 --- a/phpBB/adm/style/admin.js +++ b/phpBB/adm/style/admin.js @@ -243,11 +243,16 @@ function parse_document(container) parse_document($('body')); - $('#trigger-configlist').on('click', function () { + $('#questionnaire-form').css('display', 'none'); + var $triggerConfiglist = $('#trigger-configlist'); + + $triggerConfiglist.on('click', function () { var $configlist = $('#configlist'); $configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden'); $configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row'); $(this).find('i').toggleClass('fa-angle-down fa-angle-up'); }); + + $('#configlist').closest('.send-stats-data-row').addClass('send-stats-data-hidden'); }); })(jQuery); diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 3c1c57505b..1d4e00dfa4 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -4,6 +4,101 @@ 'use strict'; + +phpbb.prepareSendStats = function () { + var $form = $('#acp_help_phpbb'); + var $dark = $('#darkenwrapper'); + var $loadingIndicator; + + $form.on('submit', function () { + var $this = $(this), + currentTime = Math.floor(new Date().getTime() / 1000), + statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10); + + event.preventDefault(); + $this.unbind('submit'); + + // Skip ajax request if form is submitted too early or send stats + // checkbox is not checked + if (!$this.find('input[name=help_send_statistics]').is(':checked') || + statsTime > currentTime) { + $form.find('input[type=submit]').click(); + setTimeout(function () { + $form.find('input[type=submit]').click(); + }, 300); + return; + } + + /** + * Handler for AJAX errors + */ + function errorHandler(jqXHR, textStatus, errorThrown) { + if (typeof console !== 'undefined' && console.log) { + console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown); + } + phpbb.clearLoadingTimeout(); + var errorText = ''; + + if (typeof errorThrown === 'string' && errorThrown.length > 0) { + errorText = errorThrown; + } else { + errorText = $dark.attr('data-ajax-error-text-' + textStatus); + if (typeof errorText !== 'string' || !errorText.length) { + errorText = $dark.attr('data-ajax-error-text'); + } + } + phpbb.alert($dark.attr('data-ajax-error-title'), errorText); + } + + /** + * This is a private function used to handle the callbacks, refreshes + * and alert. It calls the callback, refreshes the page if necessary, and + * displays an alert to the user and removes it after an amount of time. + * + * It cannot be called from outside this function, and is purely here to + * avoid repetition of code. + * + * @param {object} res The object sent back by the server. + */ + function returnHandler(res) { + phpbb.clearLoadingTimeout(); + + // If a confirmation is not required, display an alert and call the + // callbacks. + $dark.fadeOut(phpbb.alertTime); + + if ($loadingIndicator) { + $loadingIndicator.fadeOut(phpbb.alertTime); + } + + var $sendStatisticsSuccess = $('', { + type: 'hidden', + name: 'send_statistics_response', + value: res + }); + $sendStatisticsSuccess.appendTo('p.submit-buttons'); + + // Finish actual form submission + $form.find('input[type=submit]').click(); + } + + $loadingIndicator = phpbb.loadingIndicator(); + + $.ajax({ + url: $this.attr('data-ajax-action').replace('&', '&'), + type: 'POST', + data: 'systemdata=' + $this.find('input[name=systemdata]').val(), + success: returnHandler, + error: errorHandler, + cache: false + }).always(function() { + if ($loadingIndicator && $loadingIndicator.is(':visible')) { + $loadingIndicator.fadeOut(phpbb.alertTime); + } + }); + }); +}; + /** * The following callbacks are for reording items. row_down * is triggered when an item is moved down, and row_up is triggered when @@ -225,6 +320,10 @@ $(function() { $(this).attr('data-clicked', true); }); } + + if ($('#acp_help_phpbb')) { + phpbb.prepareSendStats(); + } }); diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php index fa4de60456..cc353376cd 100644 --- a/phpBB/includes/acp/acp_help_phpbb.php +++ b/phpBB/includes/acp/acp_help_phpbb.php @@ -84,23 +84,17 @@ class acp_help_phpbb if ($submit) { $config->set('help_send_statistics', $request->variable('help_send_statistics', false)); + $response = $request->variable('send_statistics_response', ''); - if ($config['help_send_statistics']) + if (!empty($response)) { - $client = new \GuzzleHttp\Client([ - 'timeout' => 6, - 'connect_timeout' => 6, - ]); - - $response = $client->post($collect_url, [ - 'body' => [ - 'systemdata' => $collector->get_data_for_form(), - ] - ]); - $response_status = $response->getStatusCode(); - - if ($response_status >= 200 && $response_status < 300) + if ((strpos($response, 'Thank you') !== false || strpos($response, 'Flood protection') !== false)) { + // Update time when statistics were actually sent + if (strpos($response, 'Thank you') !== false) + { + $config->set('help_send_statistics_time', time()); + } trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action)); } else @@ -108,14 +102,18 @@ class acp_help_phpbb trigger_error($user->lang('FAIL_SEND_STATISTICS') . adm_back_link($this->u_action)); } } + + trigger_error($user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action)); } $template->assign_vars(array( - 'U_COLLECT_STATS' => $collect_url, - 'S_COLLECT_STATS' => (!empty($config['help_send_statistics'])) ? true : false, - 'RAW_DATA' => $collector->get_data_for_form(), - 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"), - 'U_ACTION' => $this->u_action, + 'U_COLLECT_STATS' => $collect_url, + 'S_COLLECT_STATS' => (!empty($config['help_send_statistics'])) ? true : false, + 'RAW_DATA' => $collector->get_data_for_form(), + 'U_ACP_MAIN' => append_sid("{$phpbb_admin_path}index.$phpEx"), + 'U_ACTION' => $this->u_action, + // Pass earliest time we should try to send stats again + 'COLLECT_STATS_TIME' => intval($config['help_send_statistics_time']) + 86400, )); $raw = $collector->get_data_raw(); diff --git a/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php index 4274f53520..2634cee643 100644 --- a/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php +++ b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php @@ -31,6 +31,7 @@ class add_help_phpbb extends \phpbb\db\migration\migration { 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, From eb1ade67681ee7c88845978eade07ad3ac96357a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 24 Feb 2016 13:49:20 +0100 Subject: [PATCH 20/47] [ticket/14492] Set install extensions to synthetic and fix step count PHPBB3-14492 --- .../module/install_finish/task/install_extensions.php | 7 +------ .../module/update_database/task/update_extensions.php | 2 +- tests/test_framework/phpbb_functional_test_case.php | 2 ++ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index d92f420202..bc13795188 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -97,11 +97,6 @@ class install_extensions extends \phpbb\install\task_base */ public function run() { - if (defined('PHPBB_ENVIRONMENT') && PHPBB_ENVIRONMENT === 'test') - { - return; - } - $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); @@ -134,7 +129,7 @@ class install_extensions extends \phpbb\install\task_base */ static public function get_step_count() { - return 0; + return 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 index a6648084a6..a73fa9b854 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -157,7 +157,7 @@ class enable_extensions extends task_base */ static public function get_step_count() { - return 0; + return 1; } /** diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 20b89aba4e..2a37ca0e53 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -309,6 +309,8 @@ class phpbb_functional_test_case extends phpbb_test_case $container->register('installer.install_finish.notify_user')->setSynthetic(true); $container->set('installer.install_finish.notify_user', new phpbb_mock_null_installer_task()); + $container->register('installer.install_finish.install_extensions')->setSynthetic(true); + $container->set('installer.install_finish.install_extensions', new phpbb_mock_null_installer_task()); $container->compile(); $language = $container->get('language'); From 65d6e338a99baa2f100d6bd4dea5cd76ac146ac3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 24 Feb 2016 15:05:01 +0100 Subject: [PATCH 21/47] [ticket/14492] Allow specifying extensions to update & install PHPBB3-14492 --- phpBB/language/en/install.php | 1 + .../console/command/install/install.php | 18 ++++++++++++++++++ .../install_finish/task/install_extensions.php | 9 +++++++++ .../update_database/task/update_extensions.php | 7 ++++++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 45ed51f641..054bc0a182 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -330,6 +330,7 @@ $lang = array_merge($lang, array( $lang = array_merge($lang, array( 'CLI_INSTALL_BOARD' => 'Install phpBB', 'CLI_UPDATE_BOARD' => 'Update phpBB', + 'CLI_INSTALL_EXTENSIONS' => 'Extensions to install. Multiple extensions can be specified using a comma separated list.', 'CLI_INSTALL_SHOW_CONFIG' => 'Show the configuration which will be used', 'CLI_INSTALL_VALIDATE_CONFIG' => 'Validate a configuration file', 'CLI_CONFIG_FILE' => 'Config file to use', diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index de3a2e2d61..3378f5fdac 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -80,6 +80,10 @@ class install extends \phpbb\console\command\command 'config-file', InputArgument::REQUIRED, $this->language->lang('CLI_CONFIG_FILE')) + ->addArgument( + 'install-extensions', + InputArgument::OPTIONAL, + $this->language->lang('CLI_INSTALL_EXTENSIONS')) ->setDescription($this->language->lang('CLI_INSTALL_BOARD')) ; } @@ -147,6 +151,7 @@ class install extends \phpbb\console\command\command } $this->register_configuration($iohandler, $config); + $this->register_install_extensions($iohandler, $input); try { @@ -204,4 +209,17 @@ class install extends \phpbb\console\command\command $iohandler->set_input('script_path', $config['server']['script_path']); $iohandler->set_input('submit_server', 'submit'); } + + /** + * Register extensions to install during installation + * + * @param cli_iohandler $iohandler + * @param InputInterface $input + */ + private function register_install_extensions(cli_iohandler $iohandler, InputInterface $input) + { + $install_extensions = $input->getArgument('install-extensions'); + $install_extensions = !empty($install_extensions) ? explode(',', $install_extensions) : array(); + $iohandler->set_input('install-extensions', $install_extensions); + } } diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index bc13795188..c42d17fc18 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -13,6 +13,8 @@ namespace phpbb\install\module\install_finish\task; +use Symfony\Component\Console\Input\ArgvInput; + /** * Installs extensions that exist in ext folder upon install */ @@ -100,12 +102,19 @@ class install_extensions extends \phpbb\install\task_base $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); + $install_extensions = $this->iohandler->get_input('install-extensions', array()); + // Find available extensions foreach ($this->finder as $file) { /** @var \SplFileInfo $file */ $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + if (!empty($install_extensions) && !in_array($ext_name, $install_extensions)) + { + continue; + } + if ($this->extension_manager->is_available($ext_name)) { $this->extension_manager->enable($ext_name); diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index a73fa9b854..7a65ff1803 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -18,6 +18,7 @@ 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\Console\Input\ArgvInput; use Symfony\Component\Finder\Finder; /** @@ -111,6 +112,9 @@ class enable_extensions extends task_base $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); + $input = new ArgvInput(); + $update_extensions = explode(',', $input->getArgument('update-extensions')); + $update_info = $this->install_config->get('update_info_unprocessed', array()); if (!empty($update_info)) @@ -122,7 +126,8 @@ class enable_extensions extends task_base $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); // Skip extensions that were not added or updated during update - if (!count(preg_grep('#ext/' . $ext_name . '#', $update_info['files']))) + if (!count(preg_grep('#ext/' . $ext_name . '#', $update_info['files'])) && + !in_array($ext_name, $update_extensions) && $ext_name !== 'phpbb/viglink') { continue; } From 67c3bd4a90c29a2b5c1250d3353faf823be48fad Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 29 Feb 2016 11:29:33 +0100 Subject: [PATCH 22/47] [ticket/14492] Remove incorrect changes to module order PHPBB3-14492 --- phpBB/config/installer/container/services_install_finish.yml | 2 +- phpBB/config/installer/container/services_update_database.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/config/installer/container/services_install_finish.yml b/phpBB/config/installer/container/services_install_finish.yml index 7537d86727..6a46d8f9d9 100644 --- a/phpBB/config/installer/container/services_install_finish.yml +++ b/phpBB/config/installer/container/services_install_finish.yml @@ -41,4 +41,4 @@ services: arguments: - '@installer.module.install_finish_collection' tags: - - { name: installer_install_module, order: 80 } + - { name: installer_install_module, order: 60 } diff --git a/phpBB/config/installer/container/services_update_database.yml b/phpBB/config/installer/container/services_update_database.yml index aabfceca58..bb97cff489 100644 --- a/phpBB/config/installer/container/services_update_database.yml +++ b/phpBB/config/installer/container/services_update_database.yml @@ -37,4 +37,4 @@ services: - true - false tags: - - { name: installer_update_module, order: 60 } + - { name: installer_update_module, order: 40 } From e519b21b2e563f9d751aa8f9157ccc489b660ec8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 29 Feb 2016 11:31:33 +0100 Subject: [PATCH 23/47] [ticket/14492] Only show fail of extension install if it's available PHPBB3-14492 --- .../module/install_finish/task/install_extensions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index c42d17fc18..cef2abe0cb 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -125,10 +125,10 @@ class install_extensions extends \phpbb\install\task_base // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); } - } - else - { - $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); + else + { + $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); + } } } } From 69dece6197d6289199a713e7db57cc80574aae69 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 29 Feb 2016 15:04:55 +0100 Subject: [PATCH 24/47] [ticket/14492] Removed unused use statement PHPBB3-14492 --- .../install/module/install_finish/task/install_extensions.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index cef2abe0cb..9db922b7f4 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -13,8 +13,6 @@ namespace phpbb\install\module\install_finish\task; -use Symfony\Component\Console\Input\ArgvInput; - /** * Installs extensions that exist in ext folder upon install */ From ffe900c72d358ba0337c607f2ed76f893715f686 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 11:53:20 +0100 Subject: [PATCH 25/47] [ticket/14492] Define extensions to install in config not via cli argument PHPBB3-14492 --- phpBB/docs/install-config.sample.yml | 2 ++ phpBB/docs/update-config.sample.yml | 1 + phpBB/language/en/install.php | 1 - .../console/command/install/install.php | 19 ++----------------- .../install/console/command/update/update.php | 3 +++ .../phpbb/install/installer_configuration.php | 4 ++++ phpBB/phpbb/install/updater_configuration.php | 4 ++++ 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/phpBB/docs/install-config.sample.yml b/phpBB/docs/install-config.sample.yml index 47c0324599..a354e52e2f 100644 --- a/phpBB/docs/install-config.sample.yml +++ b/phpBB/docs/install-config.sample.yml @@ -34,3 +34,5 @@ installer: server_name: localhost server_port: 80 script_path: / + + extensions: ['phpbb/viglink'] diff --git a/phpBB/docs/update-config.sample.yml b/phpBB/docs/update-config.sample.yml index f3b52a8c01..caa1a9ef1e 100644 --- a/phpBB/docs/update-config.sample.yml +++ b/phpBB/docs/update-config.sample.yml @@ -1,2 +1,3 @@ updater: type: all + extensions: ['phpbb/viglink'] diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 054bc0a182..45ed51f641 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -330,7 +330,6 @@ $lang = array_merge($lang, array( $lang = array_merge($lang, array( 'CLI_INSTALL_BOARD' => 'Install phpBB', 'CLI_UPDATE_BOARD' => 'Update phpBB', - 'CLI_INSTALL_EXTENSIONS' => 'Extensions to install. Multiple extensions can be specified using a comma separated list.', 'CLI_INSTALL_SHOW_CONFIG' => 'Show the configuration which will be used', 'CLI_INSTALL_VALIDATE_CONFIG' => 'Validate a configuration file', 'CLI_CONFIG_FILE' => 'Config file to use', diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index 3378f5fdac..52a348fe44 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -80,10 +80,6 @@ class install extends \phpbb\console\command\command 'config-file', InputArgument::REQUIRED, $this->language->lang('CLI_CONFIG_FILE')) - ->addArgument( - 'install-extensions', - InputArgument::OPTIONAL, - $this->language->lang('CLI_INSTALL_EXTENSIONS')) ->setDescription($this->language->lang('CLI_INSTALL_BOARD')) ; } @@ -151,11 +147,11 @@ class install extends \phpbb\console\command\command } $this->register_configuration($iohandler, $config); - $this->register_install_extensions($iohandler, $input); try { $this->installer->run(); + return 0; } catch (installer_exception $e) { @@ -208,18 +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'); - } - /** - * Register extensions to install during installation - * - * @param cli_iohandler $iohandler - * @param InputInterface $input - */ - private function register_install_extensions(cli_iohandler $iohandler, InputInterface $input) - { - $install_extensions = $input->getArgument('install-extensions'); - $install_extensions = !empty($install_extensions) ? explode(',', $install_extensions) : array(); - $iohandler->set_input('install-extensions', $install_extensions); + $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_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/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() ; From 930b02342e4f27f1c72fe0590f7153298331c3a6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 13:02:44 +0100 Subject: [PATCH 26/47] [ticket/14492] Check if composer.json exists in viglink folder on file_check PHPBB3-14492 --- .../phpbb/install/module/update_filesystem/task/file_check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e4e0be0531..8777b747de 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/file_check.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/file_check.php @@ -142,7 +142,7 @@ class file_check extends task_base // with it but it does not exist (e.g. deleted by admin) if (strpos($file, $this->phpbb_root_path . 'ext/phpbb/viglink') !== false && $this->update_helper->phpbb_version_compare($update_info['version']['from'], '3.2.0', '>=') && - !$this->filesystem->exists($this->phpbb_root_path . 'ext/phpbb/viglink')) + !$this->filesystem->exists($this->phpbb_root_path . 'ext/phpbb/viglink/composer.json')) { continue; } From f604e1ab5d5d780ff4bed1e39fa83cc264a8af71 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 13:54:02 +0100 Subject: [PATCH 27/47] [ticket/14492] Rework logic for selecting which extensions to update PHPBB3-14492 --- .../task/update_extensions.php | 81 ++++++++++++------- 1 file changed, 54 insertions(+), 27 deletions(-) diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 7a65ff1803..f3a977a013 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -24,7 +24,7 @@ use Symfony\Component\Finder\Finder; /** * Installs extensions that exist in ext folder upon install */ -class enable_extensions extends task_base +class update_extensions extends task_base { /** * @var config @@ -66,6 +66,14 @@ class enable_extensions extends task_base /** @var \phpbb\db\driver\driver_interface */ protected $db; + /** + * @var array List of default extensions to update, grouped by version + * they were added + */ + private $default_update = [ + '3.2.0-b2' => ['phpbb/viglink'] + ]; + /** * Constructor * @@ -112,47 +120,66 @@ class enable_extensions extends task_base $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); - $input = new ArgvInput(); - $update_extensions = explode(',', $input->getArgument('update-extensions')); + $update_info = $this->install_config->get('update_info_unprocessed', []); - $update_info = $this->install_config->get('update_info_unprocessed', array()); - - if (!empty($update_info)) + if (empty($update_info)) { - // Find available extensions - foreach ($this->finder as $file) + return; + } + + $update_extensions = $this->iohandler->get_input('update-extensions', []); + + // Create list of default extensions that need to be enabled in update + $default_update_extensions = []; + foreach ($this->default_update as $version => $extensions) + { + if ($this->update_helper->phpbb_version_compare($update_info['version']['from'], $version, '<')) { - /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + $default_update_extensions = array_merge($default_update_extensions, $extensions); + } + } - // Skip extensions that were not added or updated during update - if (!count(preg_grep('#ext/' . $ext_name . '#', $update_info['files'])) && - !in_array($ext_name, $update_extensions) && $ext_name !== 'phpbb/viglink') - { - continue; - } + // Find available extensions + foreach ($this->finder as $file) + { + /** @var \SplFileInfo $file */ + $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); - // Disable enabled extensions in order to run migrations if needed - if ($this->extension_manager->is_enabled($ext_name)) + // 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_available($ext_name) && + ( + $this->extension_manager->is_enabled($ext_name) || + in_array($ext_name, $update_extensions) || + in_array($ext_name, $default_update_extensions) + )) + { + $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 ($this->extension_manager->is_available($ext_name)) + if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { - $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)); - } + // Create log + $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); } else { $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_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); + } } } } From 64f0d74489515ad76d0caf6cfdf100ef92e16328 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 16:35:18 +0100 Subject: [PATCH 28/47] [ticket/14492] Properly retrieve version updating from PHPBB3-14492 --- .../module/update_database/task/update.php | 2 - .../task/update_extensions.php | 116 ++++++++++-------- 2 files changed, 64 insertions(+), 54 deletions(-) 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 index f3a977a013..cb5cd90952 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -26,6 +26,11 @@ use Symfony\Component\Finder\Finder; */ class update_extensions extends task_base { + /** + * @var \phpbb\cache\driver\driver_interface + */ + protected $cache; + /** * @var config */ @@ -92,8 +97,10 @@ class update_extensions extends task_base $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() @@ -121,67 +128,72 @@ class update_extensions extends task_base $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($update_info)) + if (!empty($version_from)) { - return; - } + $update_extensions = $this->iohandler->get_input('update-extensions', []); - $update_extensions = $this->iohandler->get_input('update-extensions', []); - - // Create list of default extensions that need to be enabled in update - $default_update_extensions = []; - foreach ($this->default_update as $version => $extensions) - { - if ($this->update_helper->phpbb_version_compare($update_info['version']['from'], $version, '<')) + // Create list of default extensions that need to be enabled in update + $default_update_extensions = []; + foreach ($this->default_update as $version => $extensions) { - $default_update_extensions = array_merge($default_update_extensions, $extensions); + if ($this->update_helper->phpbb_version_compare($version_from, $version, '<')) + { + $default_update_extensions = array_merge($default_update_extensions, $extensions); + } + } + + // Find available extensions + foreach ($this->finder as $file) + { + /** @var \SplFileInfo $file */ + $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + + // 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_available($ext_name) && + ( + $this->extension_manager->is_enabled($ext_name) || + in_array($ext_name, $update_extensions) || + in_array($ext_name, $default_update_extensions) + ) + ) + { + $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_ENABLE', time(), array($ext_name)); + } else + { + $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_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); + } + } } } - // Find available extensions - foreach ($this->finder as $file) - { - /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + $this->config->delete('version_update_from'); - // 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_available($ext_name) && - ( - $this->extension_manager->is_enabled($ext_name) || - in_array($ext_name, $update_extensions) || - in_array($ext_name, $default_update_extensions) - )) - { - $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(); + $this->cache->purge(); - if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) - { - // Create log - $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); - } - else - { - $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_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); - } - } - } + $this->config->increment('assets_version', 1); } /** From d62d35ad46baf9a7563a9f58038b16272cdf7c2d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 21:56:22 +0100 Subject: [PATCH 29/47] [ticket/14492] Redirect to help phpBB page after installation PHPBB3-14492 --- phpBB/phpbb/install/installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 240423ae78..b8eef34a1d 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -244,7 +244,7 @@ class installer else { global $SID; - $acp_url = $this->web_root . 'adm/index.php' . $SID; + $acp_url = $this->web_root . 'adm/index.php' . $SID . '&i=acp_help_phpbb&mode=help_phpbb'; $this->iohandler->add_success_message('INSTALLER_FINISHED', array( 'ACP_LINK', $acp_url, From fd37919ecb8e6e6618145aafae9de864fe16ded8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 22:00:08 +0100 Subject: [PATCH 30/47] [ticket/14492] Remove unused use statement PHPBB3-14492 --- .../install/module/update_database/task/update_extensions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index cb5cd90952..0a339f11e8 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -18,7 +18,6 @@ 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\Console\Input\ArgvInput; use Symfony\Component\Finder\Finder; /** From 88f197e67aab9e40e4688d6da7096dac59934101 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Mar 2016 12:33:20 +0100 Subject: [PATCH 31/47] [ticket/14492] Checkout viglink for each version depending on tags PHPBB3-14492 --- build/build.xml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/build/build.xml b/build/build.xml index 0fdf6c0cb0..ab7085eda6 100644 --- a/build/build.xml +++ b/build/build.xml @@ -289,16 +289,31 @@ + - + + + + - + + + + + + + + + From e308093d7507258855c14dcfb7214e81beac187e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Mar 2016 22:26:29 +0100 Subject: [PATCH 32/47] [ticket/14492] Use extension manager instead of finder and add try/catch PHPBB3-14492 --- .../task/install_extensions.php | 17 ++++-- .../task/update_extensions.php | 61 ++++++++++--------- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index 9db922b7f4..eb44bb780b 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -102,18 +102,17 @@ class install_extensions extends \phpbb\install\task_base $install_extensions = $this->iohandler->get_input('install-extensions', array()); - // Find available extensions - foreach ($this->finder as $file) - { - /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + $available_extensions = $this->extension_manager->all_available(); + // Install extensions + foreach ($available_extensions as $ext_name => $ext_path) + { if (!empty($install_extensions) && !in_array($ext_name, $install_extensions)) { continue; } - if ($this->extension_manager->is_available($ext_name)) + try { $this->extension_manager->enable($ext_name); $extensions = $this->get_extensions(); @@ -122,12 +121,18 @@ class install_extensions extends \phpbb\install\task_base { // 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)); + } } } diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 0a339f11e8..e8b73db25a 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -143,47 +143,52 @@ class update_extensions extends task_base } } - // Find available extensions - foreach ($this->finder as $file) - { - /** @var \SplFileInfo $file */ - $ext_name = preg_replace('#(.+[\\/\\\]ext[\\/\\\])(\w+)[\\/\\\](\w+)#', '$2/$3', dirname($file->getRealPath())); + $available_extensions = $this->extension_manager->all_available(); + // 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_available($ext_name) && - ( - $this->extension_manager->is_enabled($ext_name) || - in_array($ext_name, $update_extensions) || - in_array($ext_name, $default_update_extensions) - ) + if ($this->extension_manager->is_enabled($ext_name) || + in_array($ext_name, $update_extensions) || + in_array($ext_name, $default_update_extensions) ) { - $extension_enabled = $this->extension_manager->is_enabled($ext_name); - if ($extension_enabled) + try { - $this->extension_manager->disable($ext_name); - } - $this->extension_manager->enable($ext_name); - $extensions = $this->get_extensions(); + $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_ENABLE', time(), array($ext_name)); - } else + 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('CLI_EXTENSION_ENABLE_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_ENABLE_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); - } } } } From 2fa23c9b3f55e024f6a35c268cd7878e68ad08c2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Mar 2016 22:28:51 +0100 Subject: [PATCH 33/47] [ticket/14492] Unify version check for installing default extensions PHPBB3-14492 --- .../install/module/update_database/task/update_extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index e8b73db25a..6d0016ddb3 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -75,7 +75,7 @@ class update_extensions extends task_base * they were added */ private $default_update = [ - '3.2.0-b2' => ['phpbb/viglink'] + '3.2.0-b3' => ['phpbb/viglink'] ]; /** @@ -137,7 +137,7 @@ class update_extensions extends task_base $default_update_extensions = []; foreach ($this->default_update as $version => $extensions) { - if ($this->update_helper->phpbb_version_compare($version_from, $version, '<')) + if ($this->update_helper->phpbb_version_compare($version_from, $version, '<=')) { $default_update_extensions = array_merge($default_update_extensions, $extensions); } From 4f0627de035e7539a78e05139cfb9a5e8d59163a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Mar 2016 23:54:35 +0100 Subject: [PATCH 34/47] [ticket/14492] Add missing config to schema_data.sql PHPBB3-14492 --- phpBB/install/schemas/schema_data.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 450d2d2a52..56a4efa230 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -143,6 +143,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_sphinx_in INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_sphinx_stopwords', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('gzip_compress', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('help_send_statistics', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('help_send_statistics_time', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('hot_threshold', '25'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('icons_path', 'images/icons'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_create_thumbnail', '0'); From edfc4f3efc742342a37a5d510909aece6ae4c95d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Mar 2016 00:24:04 +0100 Subject: [PATCH 35/47] [ticket/14492] Use same list for checking if extension should be updated PHPBB3-14492 --- .../task/update_extensions.php | 4 +-- .../update_filesystem/task/file_check.php | 35 +++++++++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 6d0016ddb3..64215e2f30 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -74,7 +74,7 @@ class update_extensions extends task_base * @var array List of default extensions to update, grouped by version * they were added */ - private $default_update = [ + static public $default_extensions_update = [ '3.2.0-b3' => ['phpbb/viglink'] ]; @@ -135,7 +135,7 @@ class update_extensions extends task_base // Create list of default extensions that need to be enabled in update $default_update_extensions = []; - foreach ($this->default_update as $version => $extensions) + foreach (self::$default_extensions_update as $version => $extensions) { if ($this->update_helper->phpbb_version_compare($version_from, $version, '<=')) { 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 8777b747de..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,13 +149,25 @@ class file_check extends task_base $progress_count++; $this->iohandler->set_progress('UPDATE_CHECK_FILES', $progress_count); - // Do not copy viglink 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/phpbb/viglink') !== false && - $this->update_helper->phpbb_version_compare($update_info['version']['from'], '3.2.0', '>=') && - !$this->filesystem->exists($this->phpbb_root_path . 'ext/phpbb/viglink/composer.json')) + // 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) { - continue; + $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)) From b1596fda7f88bc0e2817a1143be6ff94ef3aae2a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Mar 2016 17:27:27 +0100 Subject: [PATCH 36/47] [ticket/14492] Prevent timeouts in install & update extensions tasks PHPBB3-14492 --- .../task/install_extensions.php | 21 ++++++++++++++++++- .../task/update_extensions.php | 20 +++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index eb44bb780b..b8a04685f6 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -13,6 +13,8 @@ namespace phpbb\install\module\install_finish\task; +use phpbb\install\exception\resource_limit_reached_exception; + /** * Installs extensions that exist in ext folder upon install */ @@ -102,7 +104,9 @@ class install_extensions extends \phpbb\install\task_base $install_extensions = $this->iohandler->get_input('install-extensions', array()); - $available_extensions = $this->extension_manager->all_available(); + $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) @@ -133,6 +137,21 @@ class install_extensions extends \phpbb\install\task_base // 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(); } } diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 64215e2f30..24b72f7b42 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -13,6 +13,7 @@ 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; @@ -143,7 +144,9 @@ class update_extensions extends task_base } } - $available_extensions = $this->extension_manager->all_available(); + $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) @@ -190,6 +193,21 @@ class update_extensions extends task_base $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_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(); } } From dee5e6e07636db7e35a82919a723907e734fbcd1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Mar 2016 17:32:25 +0100 Subject: [PATCH 37/47] [ticket/14492] Add language variables for updating extensions PHPBB3-14492 --- phpBB/language/en/acp/common.php | 1 + phpBB/language/en/cli.php | 2 ++ .../module/update_database/task/update_extensions.php | 8 ++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 5b747acd55..053671e1a2 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -819,4 +819,5 @@ $lang = array_merge($lang, array( 'LOG_EXT_ENABLE' => 'Extension enabled
» %s', 'LOG_EXT_DISABLE' => 'Extension disabled
» %s', 'LOG_EXT_PURGE' => 'Extension’s data deleted
» %s', + 'LOG_EXT_UPDATE' => 'Extension updated
» %s', )); diff --git a/phpBB/language/en/cli.php b/phpBB/language/en/cli.php index db4b5f9ec6..09f46a5cee 100644 --- a/phpBB/language/en/cli.php +++ b/phpBB/language/en/cli.php @@ -104,6 +104,8 @@ $lang = array_merge($lang, array( 'CLI_EXTENSION_NAME' => 'Name of the extension', 'CLI_EXTENSION_PURGE_FAILURE' => 'Could not purge extension %s', 'CLI_EXTENSION_PURGE_SUCCESS' => 'Successfully purged extension %s', + 'CLI_EXTENSION_UPDATE_FAILURE' => 'Could not update extension %s', + 'CLI_EXTENSION_UPDATE_SUCCESS' => 'Successfully updated extension %s', 'CLI_EXTENSION_NOT_FOUND' => 'No extensions were found.', 'CLI_EXTENSIONS_AVAILABLE' => 'Available', 'CLI_EXTENSIONS_DISABLED' => 'Disabled', diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 24b72f7b42..76904f80f1 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -174,11 +174,11 @@ class update_extensions extends task_base 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)); + $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_ENABLE_FAILURE', array($ext_name)); + $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name)); } // Disable extensions if it was disabled by the admin before @@ -190,7 +190,7 @@ class update_extensions extends task_base catch (\Exception $e) { // Add fail log and continue - $this->iohandler->add_log_message('CLI_EXTENSION_ENABLE_FAILURE', array($ext_name)); + $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name)); } } From 9f3b151dabd9cfeefd40c89c79c9e57ca5354bae Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Mar 2016 22:29:28 +0100 Subject: [PATCH 38/47] [ticket/14492] Checkout master if viglink tag does not exist for latest version PHPBB3-14492 --- build/build.xml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build/build.xml b/build/build.xml index ab7085eda6..69ecaa896c 100644 --- a/build/build.xml +++ b/build/build.xml @@ -142,6 +142,7 @@ + @@ -308,7 +309,18 @@ - + + + + + + + + + + From 1f270972084cd228e135481b766ada9941582155 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 6 Mar 2016 14:59:34 +0100 Subject: [PATCH 39/47] [ticket/14492] Install all extensions if 'all' is specified for extensions PHPBB3-14492 --- .../install/module/install_finish/task/install_extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index b8a04685f6..553a30ea28 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -111,7 +111,7 @@ class install_extensions extends \phpbb\install\task_base // Install extensions foreach ($available_extensions as $ext_name => $ext_path) { - if (!empty($install_extensions) && !in_array($ext_name, $install_extensions)) + if (!empty($install_extensions) && $install_extensions !== ['all'] && !in_array($ext_name, $install_extensions)) { continue; } From b9c284d85be82e2a8f50c20e147d1ca2352453d4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 22 Aug 2016 20:59:57 +0200 Subject: [PATCH 40/47] [ticket/14492] Update phpBB version and fix miscellaneous code issues PHPBB3-14492 --- build/build.xml | 2 +- phpBB/includes/acp/acp_help_phpbb.php | 2 +- .../install/module/update_database/task/update_extensions.php | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build/build.xml b/build/build.xml index 69ecaa896c..4fe6e0e908 100644 --- a/build/build.xml +++ b/build/build.xml @@ -291,7 +291,7 @@ diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php index cc353376cd..89f2f3d160 100644 --- a/phpBB/includes/acp/acp_help_phpbb.php +++ b/phpBB/includes/acp/acp_help_phpbb.php @@ -72,7 +72,7 @@ class acp_help_phpbb $collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config)); /** - * Event to add and/or modify acp_board configurations + * Event to modify ACP help phpBB page and/or listen to submit * * @event core.acp_help_phpbb_submit_before * @var boolean submit Do we display the form or process the submission diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 76904f80f1..01b88344e8 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -176,7 +176,8 @@ class update_extensions extends task_base // 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 + } + else { $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name)); } From e02aca839921792d9074177ddbb2bde4dae35b3f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 31 Aug 2016 21:33:56 +0200 Subject: [PATCH 41/47] [ticket/14492] Don't explicitly pass data providers by refs PHPBB3-14492 --- phpBB/includes/questionnaire/questionnaire.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index 6350f4bc5a..9699843db4 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -46,9 +46,9 @@ class phpbb_questionnaire_data_collector $this->providers = array(); } - function add_data_provider(&$provider) + function add_data_provider($provider) { - $this->providers[] = &$provider; + $this->providers[] = $provider; } /** @@ -80,7 +80,7 @@ class phpbb_questionnaire_data_collector { foreach (array_keys($this->providers) as $key) { - $provider = &$this->providers[$key]; + $provider = $this->providers[$key]; $this->data[$provider->get_identifier()] = $provider->get_data(); } $this->data['install_id'] = $this->install_id; From afe16a62724451cb5c7eca7864a3c110404f4e2a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 3 Sep 2016 10:47:20 +0200 Subject: [PATCH 42/47] [ticket/14492] Add missing event variable PHPBB3-14492 --- phpBB/adm/style/ajax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 1d4e00dfa4..28f761bc0b 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -10,7 +10,7 @@ phpbb.prepareSendStats = function () { var $dark = $('#darkenwrapper'); var $loadingIndicator; - $form.on('submit', function () { + $form.on('submit', function (event) { var $this = $(this), currentTime = Math.floor(new Date().getTime() / 1000), statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10); From c54838b25f50dca71a2f516175621a7ccd39a071 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Sep 2016 22:59:58 +0200 Subject: [PATCH 43/47] [ticket/14492] Update versions in files PHPBB3-14492 --- phpBB/docs/events.md | 4 ++-- phpBB/includes/acp/acp_help_phpbb.php | 2 +- phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php | 2 +- .../install/module/update_database/task/update_extensions.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index caaff7cb0e..619ba06c5f 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -199,13 +199,13 @@ acp_groups_position_teampage_add_button_before acp_help_phpbb_stats_after === * Location: adm/style/acp_help_phpbb.html -* Since: 3.2.0-b2 +* Since: 3.2.0-RC2 * Purpose: Add content after send statistics tile acp_help_phpbb_stats_before === * Location: adm/style/acp_help_phpbb.html -* Since: 3.2.0-b2 +* Since: 3.2.0-RC2 * Purpose: Add content before send statistics tile acp_logs_quick_select_forum_button_append diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php index 89f2f3d160..ba17ae3fb4 100644 --- a/phpBB/includes/acp/acp_help_phpbb.php +++ b/phpBB/includes/acp/acp_help_phpbb.php @@ -76,7 +76,7 @@ class acp_help_phpbb * * @event core.acp_help_phpbb_submit_before * @var boolean submit Do we display the form or process the submission - * @since 3.2.0-b2 + * @since 3.2.0-RC2 */ $vars = array('submit'); extract($phpbb_dispatcher->trigger_event('core.acp_help_phpbb_submit_before', compact($vars))); diff --git a/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php index 2634cee643..afa67fbc58 100644 --- a/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php +++ b/phpBB/phpbb/db/migration/data/v320/add_help_phpbb.php @@ -18,7 +18,7 @@ class add_help_phpbb extends \phpbb\db\migration\migration static public function depends_on() { return array( - '\phpbb\db\migration\data\v320\v320a2', + '\phpbb\db\migration\data\v320\v320rc1', ); } diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 01b88344e8..13c1591dcd 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -76,7 +76,7 @@ class update_extensions extends task_base * they were added */ static public $default_extensions_update = [ - '3.2.0-b3' => ['phpbb/viglink'] + '3.2.0-RC2' => ['phpbb/viglink'] ]; /** From 15f433f00fb84fa8afa97ae95372b7dc6826f5f5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 11 Sep 2016 16:57:33 +0200 Subject: [PATCH 44/47] [ticket/14492] Always update the time the stats were sent PHPBB3-14492 --- phpBB/includes/acp/acp_help_phpbb.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_help_phpbb.php b/phpBB/includes/acp/acp_help_phpbb.php index ba17ae3fb4..7991a0dad6 100644 --- a/phpBB/includes/acp/acp_help_phpbb.php +++ b/phpBB/includes/acp/acp_help_phpbb.php @@ -86,15 +86,12 @@ class acp_help_phpbb $config->set('help_send_statistics', $request->variable('help_send_statistics', false)); $response = $request->variable('send_statistics_response', ''); + $config->set('help_send_statistics_time', time()); + if (!empty($response)) { if ((strpos($response, 'Thank you') !== false || strpos($response, 'Flood protection') !== false)) { - // Update time when statistics were actually sent - if (strpos($response, 'Thank you') !== false) - { - $config->set('help_send_statistics_time', time()); - } trigger_error($user->lang('THANKS_SEND_STATISTICS') . adm_back_link($this->u_action)); } else From 9b4190e1365aed639068d341cb4296e895ad4ba1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 9 Nov 2016 22:02:46 +0100 Subject: [PATCH 45/47] [ticket/14492] Encode URI components in systemdata for stats The stats data needs to be URI encoded to prevent issues when submitting the data to the receive_stats script on www.phpbb.com. PHPBB3-14492 --- phpBB/adm/style/ajax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 28f761bc0b..d5154b2a61 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -87,7 +87,7 @@ phpbb.prepareSendStats = function () { $.ajax({ url: $this.attr('data-ajax-action').replace('&', '&'), type: 'POST', - data: 'systemdata=' + $this.find('input[name=systemdata]').val(), + data: 'systemdata=' + encodeURIComponent($this.find('input[name=systemdata]').val()), success: returnHandler, error: errorHandler, cache: false From 8ded30bbbe1e12ed301c2deb43d52da5a22d5b05 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 22 Nov 2016 18:39:01 +0100 Subject: [PATCH 46/47] [ticket/14492] Fix redirection to help phpBB page PHPBB3-14492 --- phpBB/phpbb/install/installer.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index b8eef34a1d..abdb172cf3 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -59,6 +59,11 @@ class installer */ protected $web_root; + /** + * @var \phpbb\user + */ + protected $user; + /** * Stores the number of steps that a given module has * @@ -87,6 +92,7 @@ class installer $this->installer_modules = null; $this->web_root = $path_helper->get_web_root_path(); $this->purge_cache_before = false; + $this->user = $container->get('user'); } /** @@ -243,8 +249,14 @@ class installer } else { - global $SID; - $acp_url = $this->web_root . 'adm/index.php' . $SID . '&i=acp_help_phpbb&mode=help_phpbb'; + // Start session and try to apply session id + $auth = $this->container_factory->get('auth'); + $this->user->session_begin(); + $auth->acl($this->user->data); + $this->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, $this->user->session_id); $this->iohandler->add_success_message('INSTALLER_FINISHED', array( 'ACP_LINK', $acp_url, From 5895f56de05b637765a6583b8c51c1db3daabe91 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Nov 2016 20:38:29 +0100 Subject: [PATCH 47/47] [ticket/14492] Add user service to installer & only instantiate if needed PHPBB3-14492 --- phpBB/config/installer/container/services.yml | 6 ++++++ phpBB/phpbb/install/installer.php | 15 +++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/phpBB/config/installer/container/services.yml b/phpBB/config/installer/container/services.yml index 4c3ed3bfcb..c16547c649 100644 --- a/phpBB/config/installer/container/services.yml +++ b/phpBB/config/installer/container/services.yml @@ -88,6 +88,12 @@ services: calls: - [setLexer, ['@template.twig.lexer']] + user: + class: phpbb\user + arguments: + - '@language' + - '%datetime.class%' + console.exception_subscriber: class: phpbb\console\exception_subscriber arguments: diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index abdb172cf3..a7d3b99dcb 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -59,11 +59,6 @@ class installer */ protected $web_root; - /** - * @var \phpbb\user - */ - protected $user; - /** * Stores the number of steps that a given module has * @@ -92,7 +87,6 @@ class installer $this->installer_modules = null; $this->web_root = $path_helper->get_web_root_path(); $this->purge_cache_before = false; - $this->user = $container->get('user'); } /** @@ -251,12 +245,13 @@ class installer { // Start session and try to apply session id $auth = $this->container_factory->get('auth'); - $this->user->session_begin(); - $auth->acl($this->user->data); - $this->user->setup(); + $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, $this->user->session_id); + $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,