aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/install/module
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2016-02-04 11:43:29 +0100
committerMarc Alexander <admin@m-a-styles.de>2016-12-03 14:20:28 +0100
commit4451db9f225d7a0e8a12503f0ff2f1393ee42467 (patch)
tree46b3dc1f6b9f13bfabd09351ae758eb5cb3bd6d9 /phpBB/phpbb/install/module
parentade5183ba1f10e3ba1aea927204e25f3b218ceb2 (diff)
downloadforums-4451db9f225d7a0e8a12503f0ff2f1393ee42467.tar
forums-4451db9f225d7a0e8a12503f0ff2f1393ee42467.tar.gz
forums-4451db9f225d7a0e8a12503f0ff2f1393ee42467.tar.bz2
forums-4451db9f225d7a0e8a12503f0ff2f1393ee42467.tar.xz
forums-4451db9f225d7a0e8a12503f0ff2f1393ee42467.zip
[ticket/14492] Apply fixes to update extensions task
The regex was also simplified. PHPBB3-14492
Diffstat (limited to 'phpBB/phpbb/install/module')
-rw-r--r--phpBB/phpbb/install/module/install_finish/task/install_extensions.php2
-rw-r--r--phpBB/phpbb/install/module/update_database/task/update_extensions.php40
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;
+ }
}