diff options
author | Marc Alexander <admin@m-a-styles.de> | 2016-03-02 16:35:18 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2016-12-03 14:23:34 +0100 |
commit | 64f0d74489515ad76d0caf6cfdf100ef92e16328 (patch) | |
tree | a4c94ae6d9e0c05c0e92a5750959bd926081e48b | |
parent | f604e1ab5d5d780ff4bed1e39fa83cc264a8af71 (diff) | |
download | forums-64f0d74489515ad76d0caf6cfdf100ef92e16328.tar forums-64f0d74489515ad76d0caf6cfdf100ef92e16328.tar.gz forums-64f0d74489515ad76d0caf6cfdf100ef92e16328.tar.bz2 forums-64f0d74489515ad76d0caf6cfdf100ef92e16328.tar.xz forums-64f0d74489515ad76d0caf6cfdf100ef92e16328.zip |
[ticket/14492] Properly retrieve version updating from
PHPBB3-14492
-rw-r--r-- | phpBB/phpbb/install/module/update_database/task/update.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/install/module/update_database/task/update_extensions.php | 112 |
2 files changed, 62 insertions, 52 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 @@ -27,6 +27,11 @@ use Symfony\Component\Finder\Finder; class update_extensions extends task_base { /** + * @var \phpbb\cache\driver\driver_interface + */ + protected $cache; + + /** * @var config */ protected $install_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); } /** |