1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 01:32:42 +01:00

(stable) Allow bin/storage renamespace to work with underscores

If the namespace is something like "test_example" we currently fail to
renamespace the dump.

(Cowboy committing this since this is currently blocking a data export.)

Test Plan:

  - Renamespaced a local dump, examined the output, saw 60 create / 60 use, reimported it.
  - Will export in production.

Auditors: chad
This commit is contained in:
epriestley 2016-09-06 06:58:35 -07:00
parent ca30df847e
commit bac8562884

View file

@ -138,9 +138,11 @@ final class PhabricatorStorageManagementRenamespaceWorkflow
$output_name)); $output_name));
} }
$name_pattern = preg_quote($from, '@');
$patterns = array( $patterns = array(
'use' => '@^(USE `)([^_]+)(_.*)$@', 'use' => '@^(USE `)('.$name_pattern.')(_.*)$@',
'create' => '@^(CREATE DATABASE /\*.*?\*/ `)([^_]+)(_.*)$@', 'create' => '@^(CREATE DATABASE /\*.*?\*/ `)('.$name_pattern.')(_.*)$@',
); );
$found = array_fill_keys(array_keys($patterns), 0); $found = array_fill_keys(array_keys($patterns), 0);
@ -151,16 +153,6 @@ final class PhabricatorStorageManagementRenamespaceWorkflow
foreach ($patterns as $key => $pattern) { foreach ($patterns as $key => $pattern) {
if (preg_match($pattern, $line, $matches)) { if (preg_match($pattern, $line, $matches)) {
$namespace = $matches[2];
if ($namespace != $from) {
throw new Exception(
pht(
'Expected namespace "%s", found "%s": %s.',
$from,
$namespace,
$line));
}
$line = $matches[1].$to.$matches[3]; $line = $matches[1].$to.$matches[3];
$found[$key]++; $found[$key]++;
} }