diff options
author | Marc Alexander <admin@m-a-styles.de> | 2016-10-25 20:25:57 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2016-10-25 20:25:57 +0200 |
commit | ffc6623dd4b66f039698d86701c49724bc217bc7 (patch) | |
tree | 020620452cc6a2a2fa6a414128b75a7f63abd205 /phpBB | |
parent | 6f8c0df1c68a2f7812c10ffd489098f50401022d (diff) | |
download | forums-ffc6623dd4b66f039698d86701c49724bc217bc7.tar forums-ffc6623dd4b66f039698d86701c49724bc217bc7.tar.gz forums-ffc6623dd4b66f039698d86701c49724bc217bc7.tar.bz2 forums-ffc6623dd4b66f039698d86701c49724bc217bc7.tar.xz forums-ffc6623dd4b66f039698d86701c49724bc217bc7.zip |
[ticket/14831] Rename migration and replace preg_replace() with simpler methods
PHPBB3-14831
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php (renamed from phpBB/phpbb/db/migration/data/v31x/migrations_deduplicate_entries.php) | 7 | ||||
-rw-r--r-- | phpBB/phpbb/db/migrator.php | 4 |
2 files changed, 5 insertions, 6 deletions
diff --git a/phpBB/phpbb/db/migration/data/v31x/migrations_deduplicate_entries.php b/phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php index 5f883952b4..417d569a09 100644 --- a/phpBB/phpbb/db/migration/data/v31x/migrations_deduplicate_entries.php +++ b/phpBB/phpbb/db/migration/data/v31x/remove_duplicate_migrations.php @@ -14,7 +14,7 @@ namespace phpbb\db\migration\data\v31x; -class migrations_deduplicate_entries extends \phpbb\db\migration\migration +class remove_duplicate_migrations extends \phpbb\db\migration\migration { static public function depends_on() { @@ -44,7 +44,6 @@ class migrations_deduplicate_entries extends \phpbb\db\migration\migration $migration_state[$migration['migration_name']] = $migration; $migration_state[$migration['migration_name']]['migration_depends_on'] = unserialize($migration['migration_depends_on']); - $migration_state[$migration['migration_name']]['migration_data_state'] = !empty($migration['migration_data_state']) ? unserialize($migration['migration_data_state']) : ''; } } @@ -52,8 +51,8 @@ class migrations_deduplicate_entries extends \phpbb\db\migration\migration foreach ($migration_state as $name => $migration) { - $prepended_name = preg_replace('#^(?!\\\)#', '\\\$0', $name); - $prefixless_name = preg_replace('#(^\\\)([^\\\].+)#', '$2', $name); + $prepended_name = ($name[0] == '\\' ? '' : '\\') . $name; + $prefixless_name = $name[0] == '\\' ? substr($name, 1) : $name; if ($prepended_name != $name && isset($migration_state[$prepended_name]) && $migration_state[$prepended_name]['migration_depends_on'] == $migration_state[$name]['migration_depends_on']) { diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index 30eafcc470..45a333ac94 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -212,8 +212,8 @@ class migrator // Try falling back to a valid migration name with or without leading backslash if (!isset($this->migration_state[$name])) { - $prepended_name = preg_replace('#^(?!\\\)#', '\\\$0', $name); - $prefixless_name = preg_replace('#(^\\\)([^\\\].+)#', '$2', $name); + $prepended_name = ($name[0] == '\\' ? '' : '\\') . $name; + $prefixless_name = $name[0] == '\\' ? substr($name, 1) : $name; if (isset($this->migration_state[$prepended_name])) { |