Differential D14463 Diff 35378 src/infrastructure/storage/management/workflow/PhabricatorStorageManagementQuickstartWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementQuickstartWorkflow.php
| Show All 16 Lines | $this | ||||
| 'name' => 'output', | 'name' => 'output', | ||||
| 'param' => 'file', | 'param' => 'file', | ||||
| 'help' => pht('Specify output file to write.'), | 'help' => pht('Specify output file to write.'), | ||||
| ), | ), | ||||
| )); | )); | ||||
| } | } | ||||
| public function execute(PhutilArgumentParser $args) { | public function execute(PhutilArgumentParser $args) { | ||||
| parent::execute($args); | |||||
| $output = $args->getArg('output'); | $output = $args->getArg('output'); | ||||
| if (!$output) { | if (!$output) { | ||||
| throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
| pht( | pht( | ||||
| 'Specify a file to write with `%s`.', | 'Specify a file to write with `%s`.', | ||||
| '--output')); | '--output')); | ||||
| } | } | ||||
| $namespace = 'phabricator_quickstart_'.Filesystem::readRandomCharacters(8); | $namespace = 'phabricator_quickstart_'.Filesystem::readRandomCharacters(8); | ||||
| $bin = dirname(phutil_get_library_root('phabricator')).'/bin/storage'; | $bin = dirname(phutil_get_library_root('phabricator')).'/bin/storage'; | ||||
| if (!$this->getAPI()->isCharacterSetAvailable('utf8mb4')) { | if (!$this->getAPI()->isCharacterSetAvailable('utf8mb4')) { | ||||
| throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
| pht( | pht( | ||||
| 'You can only generate a new quickstart file if MySQL supports '. | 'You can only generate a new quickstart file if MySQL supports '. | ||||
| 'the utf8mb4 character set (available in MySQL 5.5 and newer). The '. | 'the %s character set (available in MySQL 5.5 and newer). The '. | ||||
| 'configured server does not support utf8mb4.')); | 'configured server does not support %s.', | ||||
| 'utf8mb4', | |||||
| 'utf8mb4')); | |||||
| } | } | ||||
| $err = phutil_passthru( | $err = phutil_passthru( | ||||
| '%s upgrade --force --no-quickstart --namespace %s', | '%s upgrade --force --no-quickstart --namespace %s', | ||||
| $bin, | $bin, | ||||
| $namespace); | $namespace); | ||||
| if ($err) { | if ($err) { | ||||
| return $err; | return $err; | ||||
| ▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | $dump = preg_replace( | ||||
| '(^/\*.*\*/;$)m', | '(^/\*.*\*/;$)m', | ||||
| '', | '', | ||||
| $dump); | $dump); | ||||
| // Remove comments. | // Remove comments. | ||||
| $dump = preg_replace('/^--.*$/m', '', $dump); | $dump = preg_replace('/^--.*$/m', '', $dump); | ||||
| // Remove table drops, locks, and unlocks. These are never relevant when | // Remove table drops, locks, and unlocks. These are never relevant when | ||||
| // performing q quickstart. | // performing a quickstart. | ||||
| $dump = preg_replace( | $dump = preg_replace( | ||||
| '/^(DROP TABLE|LOCK TABLES|UNLOCK TABLES).*$/m', | '/^(DROP TABLE|LOCK TABLES|UNLOCK TABLES).*$/m', | ||||
| '', | '', | ||||
| $dump); | $dump); | ||||
| // Collapse adjacent newlines. | // Collapse adjacent newlines. | ||||
| $dump = preg_replace('/\n\s*\n/', "\n", $dump); | $dump = preg_replace('/\n\s*\n/', "\n", $dump); | ||||
| Show All 15 Lines | |||||