From f205c4fad4c3a82cc4a47beb7f9a8025669a3acb Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 19 Sep 2013 17:03:05 +0200 Subject: [ticket/11700] Change search backend db entry to namespaces PHPBB3-11700 --- phpBB/phpbb/db/migration/data/v310/namespaces.php | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/namespaces.php (limited to 'phpBB/phpbb/db/migration/data/v310/namespaces.php') diff --git a/phpBB/phpbb/db/migration/data/v310/namespaces.php b/phpBB/phpbb/db/migration/data/v310/namespaces.php new file mode 100644 index 0000000000..6da015d0da --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/namespaces.php @@ -0,0 +1,30 @@ +config['search_type'])), + array('config.update', array('search_type', str_replace('phpbb_search_', 'phpbb\\search\\', $this->config['search_type']))), + )), + ); + } +} -- cgit v1.2.1 From 9373c0db9683dc0659545a28f904cc34c13d6be8 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 25 Sep 2013 14:40:12 +0200 Subject: [ticket/11700] Only replace phpbb_search in strings that match PHPBB3-11700 --- phpBB/phpbb/db/migration/data/v310/namespaces.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/db/migration/data/v310/namespaces.php') diff --git a/phpBB/phpbb/db/migration/data/v310/namespaces.php b/phpBB/phpbb/db/migration/data/v310/namespaces.php index 6da015d0da..9b182f88b8 100644 --- a/phpBB/phpbb/db/migration/data/v310/namespaces.php +++ b/phpBB/phpbb/db/migration/data/v310/namespaces.php @@ -22,7 +22,7 @@ class namespaces extends \phpbb\db\migration\migration { return array( array('if', array( - (preg_match('#^phpbb_#', $this->config['search_type'])), + (preg_match('#^phpbb_search_#', $this->config['search_type'])), array('config.update', array('search_type', str_replace('phpbb_search_', 'phpbb\\search\\', $this->config['search_type']))), )), ); -- cgit v1.2.1 From cbc458e4768107e30688224e173c26493b971a41 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 25 Sep 2013 16:09:14 +0200 Subject: [ticket/11700] Update migrations table for namespaces PHPBB3-11700 --- phpBB/phpbb/db/migration/data/v310/namespaces.php | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'phpBB/phpbb/db/migration/data/v310/namespaces.php') 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; + } } -- cgit v1.2.1 From 645bd127dd53300b7877b779226ac53a4891620c Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 25 Sep 2013 16:20:26 +0200 Subject: [ticket/11700] Undo migrations migration, as not an issue for new installs PHPBB3-11700 --- phpBB/phpbb/db/migration/data/v310/namespaces.php | 55 ----------------------- 1 file changed, 55 deletions(-) (limited to 'phpBB/phpbb/db/migration/data/v310/namespaces.php') diff --git a/phpBB/phpbb/db/migration/data/v310/namespaces.php b/phpBB/phpbb/db/migration/data/v310/namespaces.php index 3dd65e09e4..9b182f88b8 100644 --- a/phpBB/phpbb/db/migration/data/v310/namespaces.php +++ b/phpBB/phpbb/db/migration/data/v310/namespaces.php @@ -25,61 +25,6 @@ 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; - } } -- cgit v1.2.1