aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2016-03-03 22:26:29 +0100
committerMarc Alexander <admin@m-a-styles.de>2016-12-03 14:23:34 +0100
commite308093d7507258855c14dcfb7214e81beac187e (patch)
tree66153ab892b95a1a3cbff3a6ce5922838400477c /phpBB
parent88f197e67aab9e40e4688d6da7096dac59934101 (diff)
downloadforums-e308093d7507258855c14dcfb7214e81beac187e.tar
forums-e308093d7507258855c14dcfb7214e81beac187e.tar.gz
forums-e308093d7507258855c14dcfb7214e81beac187e.tar.bz2
forums-e308093d7507258855c14dcfb7214e81beac187e.tar.xz
forums-e308093d7507258855c14dcfb7214e81beac187e.zip
[ticket/14492] Use extension manager instead of finder and add try/catch
PHPBB3-14492
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/phpbb/install/module/install_finish/task/install_extensions.php17
-rw-r--r--phpBB/phpbb/install/module/update_database/task/update_extensions.php61
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);
+ $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);
- }
}
}
}