From 8f5a0ad6f73e7b7757b02c827436384c96069b5a Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Fri, 24 Jul 2015 09:20:50 +0200 Subject: [ticket/14039] Revamp updater PHPBB3-14039 --- .../install/module/update_database/task/update.php | 212 +++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 phpBB/phpbb/install/module/update_database/task/update.php (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php new file mode 100644 index 0000000000..2d640134a3 --- /dev/null +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -0,0 +1,212 @@ + + * @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\db\migration\exception; +use phpbb\db\output_handler\installer_migrator_output_handler; +use phpbb\db\output_handler\log_wrapper_migrator_output_handler; +use phpbb\install\exception\resource_limit_reached_exception; +use phpbb\install\exception\user_interaction_required_exception; +use phpbb\install\task_base; + +/** + * Database updater task + */ +class update extends task_base +{ + /** + * @var \phpbb\cache\driver\driver_interface + */ + protected $cache; + + /** + * @var \phpbb\config\config + */ + protected $config; + + /** + * @var \phpbb\extension\manager + */ + protected $extension_manager; + + /** + * @var \phpbb\filesystem\filesystem + */ + protected $filesystem; + + /** + * @var \phpbb\install\helper\config + */ + protected $installer_config; + + /** + * @var \phpbb\install\helper\iohandler\iohandler_interface + */ + protected $iohandler; + + /** + * @var \phpbb\language\language + */ + protected $language; + + /** + * @var \phpbb\log\log + */ + protected $log; + + /** + * @var \phpbb\db\migrator + */ + protected $migrator; + + /** + * @var \phpbb\user + */ + protected $user; + + /** + * @var string + */ + protected $phpbb_root_path; + + /** + * Constructor + * + * @param \phpbb\install\helper\container_factory $container + * @param \phpbb\filesystem\filesystem $filesystem + * @param \phpbb\install\helper\config $installer_config + * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler + * @param \phpbb\language\language $language + * @param string $phpbb_root_path + */ + public function __construct(\phpbb\install\helper\container_factory $container, \phpbb\filesystem\filesystem $filesystem, \phpbb\install\helper\config $installer_config, \phpbb\install\helper\iohandler\iohandler_interface $iohandler, \phpbb\language\language $language, $phpbb_root_path) + { + $this->filesystem = $filesystem; + $this->installer_config = $installer_config; + $this->iohandler = $iohandler; + $this->language = $language; + $this->phpbb_root_path = $phpbb_root_path; + + $this->cache = $container->get('cache.driver'); + $this->config = $container->get('config'); + $this->extension_manager = $container->get('ext.manager'); + $this->log = $container->get('log'); + $this->migrator = $container->get('migrator'); + $this->user = $container->get('user'); + + parent::__construct(true); + } + + /** + * {@inheritdoc} + */ + public function run() + { + $this->language->add_lang('migrator'); + + if (!isset($this->config['version_update_from'])) + { + $this->config->set('version_update_from', $this->config['version']); + } + + $original_version = $this->config['version_update_from']; + + $this->migrator->set_output_handler( + new log_wrapper_migrator_output_handler( + $this->language, + new installer_migrator_output_handler($this->iohandler), + $this->phpbb_root_path . 'store/migrations_' . time() . '.log', + $this->filesystem + ) + ); + + $this->migrator->create_migrations_table(); + + $migrations = $this->extension_manager + ->get_finder() + ->core_path('phpbb/db/migration/data/') + ->extension_directory('/migrations') + ->get_classes(); + + $this->migrator->set_migrations($migrations); + $migration_count = count($migrations); + $this->iohandler->set_task_count($migration_count, true); + $progress_count = $this->installer_config->get('database_update_count', 0); + + while (!$this->migrator->finished()) + { + try + { + $this->migrator->update(); + $progress_count++; + $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); + } + catch (exception $e) + { + $msg = $e->getParameters(); + array_unshift($msg, $e->getMessage()); + + $this->iohandler->add_error_message($msg); + throw new user_interaction_required_exception(); + } + + if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) + { + $this->installer_config->set('database_update_count', $progress_count); + throw new resource_limit_reached_exception(); + } + } + + if ($original_version !== $this->config['version']) + { + $this->log->add( + 'admin', + $this->user->data['user_id'], + $this->user->ip, + 'LOG_UPDATE_DATABASE', + false, + array( + $original_version, + $this->config['version'] + ) + ); + } + + $this->iohandler->finish_progress('INLINE_UPDATE_SUCCESSFUL'); + + $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); + + $this->config->delete('version_update_from'); + + $this->cache->purge(); + + $this->config->increment('assets_version', 1); + } + + /** + * {@inheritdoc} + */ + static public function get_step_count() + { + return 0; + } + + /** + * {@inheritdoc} + */ + public function get_task_lang_name() + { + return ''; + } +} -- cgit v1.2.1 From d77455309b0edbcc65e4a347dc777542b1189328 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 9 Nov 2015 15:27:10 +0100 Subject: [ticket/14278] Check if user_id is set and fall back to ANONYMOUS PHPBB3-14278 --- phpBB/phpbb/install/module/update_database/task/update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 2d640134a3..84ec6f73f5 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -172,7 +172,7 @@ class update extends task_base { $this->log->add( 'admin', - $this->user->data['user_id'], + (isset($this->user->data['user_id'])) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, -- cgit v1.2.1 From fb1acb0ef463bc38421248497e7f0b7b271600f7 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 28 Jan 2016 07:04:55 -0800 Subject: [ticket/14434] Check migrations in the database updater task PHPBB3-14434 --- phpBB/phpbb/install/module/update_database/task/update.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 84ec6f73f5..eb9bdc8138 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -139,6 +139,15 @@ class update extends task_base ->extension_directory('/migrations') ->get_classes(); + // Unset classes that are not a valid migration + foreach ($migrations as $key => $migration_class) + { + if (\phpbb\db\migrator::is_migration($migration_class) === false) + { + unset($migrations[$key]); + } + } + $this->migrator->set_migrations($migrations); $migration_count = count($migrations); $this->iohandler->set_task_count($migration_count, true); -- cgit v1.2.1 From 27027deb9ce2076f64dbfdecba494efe1aa523dc Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 28 Jan 2016 11:22:30 -0800 Subject: [ticket/14434] Refactored to check migrations when setting them PHPBB3-14434 --- phpBB/phpbb/install/module/update_database/task/update.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index eb9bdc8138..4b2baf2c23 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -139,17 +139,8 @@ class update extends task_base ->extension_directory('/migrations') ->get_classes(); - // Unset classes that are not a valid migration - foreach ($migrations as $key => $migration_class) - { - if (\phpbb\db\migrator::is_migration($migration_class) === false) - { - unset($migrations[$key]); - } - } - $this->migrator->set_migrations($migrations); - $migration_count = count($migrations); + $migration_count = count($this->migrator->get_migrations()); $this->iohandler->set_task_count($migration_count, true); $progress_count = $this->installer_config->get('database_update_count', 0); -- cgit v1.2.1 From 2f6f9a05eb1ae25a29fcb90bb301ce507298a474 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 4 Feb 2016 21:20:02 +0100 Subject: [ticket/14312] Push migration error messages to the user PHPBB3-14312 --- phpBB/phpbb/install/module/update_database/task/update.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 4b2baf2c23..aa44d403dd 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -158,6 +158,7 @@ class update extends task_base array_unshift($msg, $e->getMessage()); $this->iohandler->add_error_message($msg); + $this->iohandler->send_response(); throw new user_interaction_required_exception(); } -- cgit v1.2.1 From 955b9ede33c5696173a760ea271ec32d79e843b9 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Thu, 11 Feb 2016 13:18:30 +0100 Subject: [ticket/14462] Further speed improvements - Cache the secondary container - Only initialize tasks/modules that are being used - Add timeout error message in the AJAX UI PHPBB3-14462 --- phpBB/phpbb/install/module/update_database/task/update.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index aa44d403dd..4b2baf2c23 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -158,7 +158,6 @@ class update extends task_base array_unshift($msg, $e->getMessage()); $this->iohandler->add_error_message($msg); - $this->iohandler->send_response(); throw new user_interaction_required_exception(); } -- cgit v1.2.1 From 3278ff03e7809dd0bb31771b3928e8676a09c572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Sun, 27 Mar 2016 18:25:06 +0200 Subject: [ticket/14393] Fix updater behaviour PHPBB3-14393 --- phpBB/phpbb/install/module/update_database/task/update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 4b2baf2c23..d8807951d1 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -183,7 +183,7 @@ class update extends task_base ); } - $this->iohandler->finish_progress('INLINE_UPDATE_SUCCESSFUL'); + $this->iohandler->set_progress('INLINE_UPDATE_SUCCESSFUL', $migration_count); $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); -- cgit v1.2.1 From 9fc01a42e678a934507dede60b9e1e806ccfd787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Wed, 30 Mar 2016 11:05:45 +0200 Subject: [ticket/14393] Fix db update progress bar PHPBB3-14393 --- phpBB/phpbb/install/module/update_database/task/update.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index d8807951d1..9fed2317e9 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -142,6 +142,7 @@ class update extends task_base $this->migrator->set_migrations($migrations); $migration_count = count($this->migrator->get_migrations()); $this->iohandler->set_task_count($migration_count, true); + $this->installer_config->set_task_progress_count($migration_count); $progress_count = $this->installer_config->get('database_update_count', 0); while (!$this->migrator->finished()) @@ -183,8 +184,6 @@ class update extends task_base ); } - $this->iohandler->set_progress('INLINE_UPDATE_SUCCESSFUL', $migration_count); - $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); $this->config->delete('version_update_from'); -- cgit v1.2.1 From 03be89ebd7bfd95e8586d0d13076a90afec243ee Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 11 Aug 2016 23:28:54 +0200 Subject: [ticket/14742] Fix progress bar in database updater Because of the new way, schema update steps are handled, the already misleading progress bar was even more misleading. This should fix it. PHPBB3-14742 --- .../install/module/update_database/task/update.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index 9fed2317e9..d167181125 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -140,7 +140,14 @@ class update extends task_base ->get_classes(); $this->migrator->set_migrations($migrations); - $migration_count = count($this->migrator->get_migrations()); + + $migration_count = $this->installer_config->get('database_update_migrations', -1); + if ($migration_count < 0) + { + $migration_count = count($this->migrator->get_installable_migrations()); + $this->installer_config->set('database_update_migrations', $migration_count); + } + $this->iohandler->set_task_count($migration_count, true); $this->installer_config->set_task_progress_count($migration_count); $progress_count = $this->installer_config->get('database_update_count', 0); @@ -150,8 +157,14 @@ class update extends task_base try { $this->migrator->update(); - $progress_count++; - $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); + + $last_run_migration = $this->migrator->get_last_run_migration(); + + if ($last_run_migration['state']['migration_data_done']) + { + $progress_count++; + $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); + } } catch (exception $e) { -- cgit v1.2.1 From 758fe20f4be7178fd4b9fd6ce48c5342cfcbce27 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 12 Aug 2016 03:45:56 +0200 Subject: [ticket/14742] Further improve progress bar in db updater PHPBB3-14742 --- .../install/module/update_database/task/update.php | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index d167181125..c69dafaa10 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -141,16 +141,17 @@ class update extends task_base $this->migrator->set_migrations($migrations); - $migration_count = $this->installer_config->get('database_update_migrations', -1); - if ($migration_count < 0) + $migration_step_count = $this->installer_config->get('database_update_migration_steps', -1); + if ($migration_step_count < 0) { - $migration_count = count($this->migrator->get_installable_migrations()); - $this->installer_config->set('database_update_migrations', $migration_count); + $migration_step_count = count($this->migrator->get_installable_migrations()) * 2; + $this->installer_config->set('database_update_migration_steps', $migration_step_count); } - $this->iohandler->set_task_count($migration_count, true); - $this->installer_config->set_task_progress_count($migration_count); $progress_count = $this->installer_config->get('database_update_count', 0); + $restart_progress_bar = ($progress_count === 0); // Only "restart" when the update runs for the first time + $this->iohandler->set_task_count($migration_step_count, $restart_progress_bar); + $this->installer_config->set_task_progress_count($migration_step_count); while (!$this->migrator->finished()) { @@ -159,12 +160,17 @@ class update extends task_base $this->migrator->update(); $last_run_migration = $this->migrator->get_last_run_migration(); - - if ($last_run_migration['state']['migration_data_done']) + if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed']) + { + $progress_count += 2; + } + else if (($last_run_migration['task'] === 'process_schema_step' && $last_run_migration['state']['migration_schema_done']) || + ($last_run_migration['task'] === 'process_data_step' && $last_run_migration['state']['migration_data_done'])) { $progress_count++; - $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); } + + $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); } catch (exception $e) { -- cgit v1.2.1 From a37f10ae0951f16b115f4a175cc546a515cf7937 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 20 Aug 2016 22:40:37 +0200 Subject: [ticket/14742] Increase user feedback by improving progress bar We now count and display each step that was done by increasing the task count. PHPBB3-14742 --- phpBB/phpbb/install/module/update_database/task/update.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') diff --git a/phpBB/phpbb/install/module/update_database/task/update.php b/phpBB/phpbb/install/module/update_database/task/update.php index c69dafaa10..9d7ba2f919 100644 --- a/phpBB/phpbb/install/module/update_database/task/update.php +++ b/phpBB/phpbb/install/module/update_database/task/update.php @@ -158,18 +158,23 @@ class update extends task_base try { $this->migrator->update(); + $progress_count++; $last_run_migration = $this->migrator->get_last_run_migration(); if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed']) { - $progress_count += 2; + // We skipped two step, so increment $progress_count by another one + $progress_count++; } - else if (($last_run_migration['task'] === 'process_schema_step' && $last_run_migration['state']['migration_schema_done']) || - ($last_run_migration['task'] === 'process_data_step' && $last_run_migration['state']['migration_data_done'])) + else if (($last_run_migration['task'] === 'process_schema_step' && !$last_run_migration['state']['migration_schema_done']) || + ($last_run_migration['task'] === 'process_data_step' && !$last_run_migration['state']['migration_data_done'])) { - $progress_count++; + // We just run a step that wasn't counted yet so make it count + $migration_step_count++; } + $this->iohandler->set_task_count($migration_step_count); + $this->installer_config->set_task_progress_count($migration_step_count); $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); } catch (exception $e) @@ -184,6 +189,7 @@ class update extends task_base if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) { $this->installer_config->set('database_update_count', $progress_count); + $this->installer_config->set('database_update_migration_steps', $migration_step_count); throw new resource_limit_reached_exception(); } } -- cgit v1.2.1 From 267d1b15c4884dd67a299b2428251e68cd55327b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 29 Jan 2016 10:13:06 +0100 Subject: [ticket/14492] Re-enable extensions if updated during update PHPBB3-14492 --- .../update_database/task/update_extensions.php | 162 +++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 phpBB/phpbb/install/module/update_database/task/update_extensions.php (limited to 'phpBB/phpbb/install/module/update_database/task') 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'; + } +} -- cgit v1.2.1 From 4451db9f225d7a0e8a12503f0ff2f1393ee42467 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 4 Feb 2016 11:43:29 +0100 Subject: [ticket/14492] Apply fixes to update extensions task The regex was also simplified. PHPBB3-14492 --- .../update_database/task/update_extensions.php | 40 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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; + } } -- cgit v1.2.1 From eb1ade67681ee7c88845978eade07ad3ac96357a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 24 Feb 2016 13:49:20 +0100 Subject: [ticket/14492] Set install extensions to synthetic and fix step count PHPBB3-14492 --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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; } /** -- cgit v1.2.1 From 65d6e338a99baa2f100d6bd4dea5cd76ac146ac3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 24 Feb 2016 15:05:01 +0100 Subject: [ticket/14492] Allow specifying extensions to update & install PHPBB3-14492 --- .../install/module/update_database/task/update_extensions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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; } -- cgit v1.2.1 From f604e1ab5d5d780ff4bed1e39fa83cc264a8af71 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 13:54:02 +0100 Subject: [ticket/14492] Rework logic for selecting which extensions to update PHPBB3-14492 --- .../update_database/task/update_extensions.php | 81 ++++++++++++++-------- 1 file changed, 54 insertions(+), 27 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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)) + { + return; + } - if (!empty($update_info)) + $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) { - // Find available extensions - foreach ($this->finder as $file) + 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())); - - // 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; - } + $default_update_extensions = array_merge($default_update_extensions, $extensions); + } + } - // Disable enabled extensions in order to run migrations if needed - if ($this->extension_manager->is_enabled($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())); + + // 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); + } } } } -- cgit v1.2.1 From 64f0d74489515ad76d0caf6cfdf100ef92e16328 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 16:35:18 +0100 Subject: [ticket/14492] Properly retrieve version updating from PHPBB3-14492 --- .../install/module/update_database/task/update.php | 2 - .../update_database/task/update_extensions.php | 112 ++++++++++++--------- 2 files changed, 62 insertions(+), 52 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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, '<')) - { - $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) - )) + // Create list of default extensions that need to be enabled in update + $default_update_extensions = []; + foreach ($this->default_update as $version => $extensions) { - $extension_enabled = $this->extension_manager->is_enabled($ext_name); - if ($extension_enabled) + if ($this->update_helper->phpbb_version_compare($version_from, $version, '<')) { - $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)); + $default_update_extensions = array_merge($default_update_extensions, $extensions); } + } - // Disable extensions if it was disabled by the admin before - if (!$extension_enabled && !in_array($ext_name, $default_update_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) + ) + ) { - $this->extension_manager->disable($ext_name); + $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); + } } } } + + $this->config->delete('version_update_from'); + + $this->cache->purge(); + + $this->config->increment('assets_version', 1); } /** -- cgit v1.2.1 From fd37919ecb8e6e6618145aafae9de864fe16ded8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Mar 2016 22:00:08 +0100 Subject: [ticket/14492] Remove unused use statement PHPBB3-14492 --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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; /** -- cgit v1.2.1 From e308093d7507258855c14dcfb7214e81beac187e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Mar 2016 22:26:29 +0100 Subject: [ticket/14492] Use extension manager instead of finder and add try/catch PHPBB3-14492 --- .../update_database/task/update_extensions.php | 61 ++++++++++++---------- 1 file changed, 33 insertions(+), 28 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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); + $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)); + $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); + } } - $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 + 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); - } } } } -- cgit v1.2.1 From 2fa23c9b3f55e024f6a35c268cd7878e68ad08c2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Mar 2016 22:28:51 +0100 Subject: [ticket/14492] Unify version check for installing default extensions PHPBB3-14492 --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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); } -- cgit v1.2.1 From edfc4f3efc742342a37a5d510909aece6ae4c95d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Mar 2016 00:24:04 +0100 Subject: [ticket/14492] Use same list for checking if extension should be updated PHPBB3-14492 --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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, '<=')) { -- cgit v1.2.1 From b1596fda7f88bc0e2817a1143be6ff94ef3aae2a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Mar 2016 17:27:27 +0100 Subject: [ticket/14492] Prevent timeouts in install & update extensions tasks PHPBB3-14492 --- .../update_database/task/update_extensions.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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(); } } -- cgit v1.2.1 From dee5e6e07636db7e35a82919a723907e734fbcd1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Mar 2016 17:32:25 +0100 Subject: [ticket/14492] Add language variables for updating extensions PHPBB3-14492 --- .../install/module/update_database/task/update_extensions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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)); } } -- cgit v1.2.1 From b9c284d85be82e2a8f50c20e147d1ca2352453d4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 22 Aug 2016 20:59:57 +0200 Subject: [ticket/14492] Update phpBB version and fix miscellaneous code issues PHPBB3-14492 --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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)); } -- cgit v1.2.1 From c54838b25f50dca71a2f516175621a7ccd39a071 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 9 Sep 2016 22:59:58 +0200 Subject: [ticket/14492] Update versions in files PHPBB3-14492 --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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'] ]; /** -- cgit v1.2.1 From 9bbd034a4e818fbfef657e04c2a87c889af640af Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 7 Jan 2017 14:44:04 +0100 Subject: [prep-release-3.2.0] Correctly compare extensions version --- phpBB/phpbb/install/module/update_database/task/update_extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/install/module/update_database/task') 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 13c1591dcd..b66847b243 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -138,7 +138,7 @@ class update_extensions extends task_base $default_update_extensions = []; foreach (self::$default_extensions_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); } -- cgit v1.2.1