aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2013-09-25 16:09:14 +0200
committerNils Adermann <naderman@naderman.de>2013-09-25 16:09:14 +0200
commitcbc458e4768107e30688224e173c26493b971a41 (patch)
tree8a5201a4cc1992e1c7c42213df227efdb3eaa002 /phpBB
parent9373c0db9683dc0659545a28f904cc34c13d6be8 (diff)
downloadforums-cbc458e4768107e30688224e173c26493b971a41.tar
forums-cbc458e4768107e30688224e173c26493b971a41.tar.gz
forums-cbc458e4768107e30688224e173c26493b971a41.tar.bz2
forums-cbc458e4768107e30688224e173c26493b971a41.tar.xz
forums-cbc458e4768107e30688224e173c26493b971a41.zip
[ticket/11700] Update migrations table for namespaces
PHPBB3-11700
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/phpbb/db/migration/data/v310/namespaces.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/phpBB/phpbb/db/migration/data/v310/namespaces.php b/phpBB/phpbb/db/migration/data/v310/namespaces.php
index 9b182f88b8..3dd65e09e4 100644
--- a/phpBB/phpbb/db/migration/data/v310/namespaces.php
+++ b/phpBB/phpbb/db/migration/data/v310/namespaces.php
@@ -25,6 +25,61 @@ class namespaces extends \phpbb\db\migration\migration
(preg_match('#^phpbb_search_#', $this->config['search_type'])),
array('config.update', array('search_type', str_replace('phpbb_search_', 'phpbb\\search\\', $this->config['search_type']))),
)),
+ array('custom', array(array($this, 'update_migrations'))),
);
}
+
+ public function update_migrations()
+ {
+ $table = $this->table_prefix . 'migrations';
+
+ $sql = 'SELECT *
+ FROM migrations';
+ $result = $this->db->sql_query($sql);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $migration_name = $row['migration_name'];
+
+ $row['migration_name'] = $this->namespacify($row['migration_name']);
+
+ $depends_on = ($row['migration_depends_on']) ? unserialize($row['migration_depends_on']) : false;
+
+ if ($depends_on)
+ {
+ $depends_on_new = array();
+
+ foreach ($depends_on as $migration)
+ {
+ $depends_on_new[] = $this->namespacify($migration);
+ }
+
+ $depends_on = serialize($depends_on_new);
+ $row['migration_depends_on'] = $depends_on;
+ }
+
+ $sql_update = $this->db->sql_build_array('UPDATE', $row);
+
+ $sql = 'UPDATE ' . MODULES_TABLE . '
+ SET ' . $sql_update . '
+ WHERE module_id = ' . $migration_name;
+ $this->sql_query($sql);
+ }
+ }
+
+ public function namespacify($migration_name)
+ {
+ $parts = explode('_', $migration_name);
+
+ $namespace = '';
+ $class = '';
+
+ while (count($parts) > 1 && (!$class || !class_exists($class)))
+ {
+ $namespace = $namespace . '\\' . array_shift($parts);
+ $class = $namespace . '\\' . implode('_', $parts);
+ }
+
+ return $class;
+ }
}