Differential D16848 Diff 40576 src/infrastructure/storage/management/workflow/PhabricatorStorageManagementQuickstartWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementQuickstartWorkflow.php
| Show All 30 Lines | if (!$output) { | ||||
| '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')) { | // We don't care which database we're using to generate a quickstart file, | ||||
| // since all of the schemata should be identical. | |||||
| $api = $this->getAnyAPI(); | |||||
| $ref = $api->getRef(); | |||||
| $ref_key = $ref->getRefKey(); | |||||
| if (!$api->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 %s 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 %s.', | 'configured server does not support %s.', | ||||
| 'utf8mb4', | 'utf8mb4', | ||||
| 'utf8mb4')); | 'utf8mb4')); | ||||
| } | } | ||||
| $err = phutil_passthru( | $err = phutil_passthru( | ||||
| '%s upgrade --force --no-quickstart --namespace %s', | '%s upgrade --force --no-quickstart --namespace %s --ref %s', | ||||
| $bin, | $bin, | ||||
| $namespace); | $namespace, | ||||
| $ref_key); | |||||
| if ($err) { | if ($err) { | ||||
| return $err; | return $err; | ||||
| } | } | ||||
| $err = phutil_passthru( | $err = phutil_passthru( | ||||
| '%s adjust --force --namespace %s', | '%s adjust --force --namespace %s --ref %s', | ||||
| $bin, | $bin, | ||||
| $namespace); | $namespace, | ||||
| $ref_key); | |||||
| if ($err) { | if ($err) { | ||||
| return $err; | return $err; | ||||
| } | } | ||||
| $tmp = new TempFile(); | $tmp = new TempFile(); | ||||
| $err = phutil_passthru( | $err = phutil_passthru( | ||||
| '%s dump --namespace %s > %s', | '%s dump --namespace %s --ref %s > %s', | ||||
| $bin, | $bin, | ||||
| $namespace, | $namespace, | ||||
| $ref_key, | |||||
| $tmp); | $tmp); | ||||
| if ($err) { | if ($err) { | ||||
| return $err; | return $err; | ||||
| } | } | ||||
| $err = phutil_passthru( | $err = phutil_passthru( | ||||
| '%s destroy --force --namespace %s', | '%s destroy --force --namespace %s --ref %s', | ||||
| $bin, | $bin, | ||||
| $namespace); | $namespace, | ||||
| $ref_key); | |||||
| if ($err) { | if ($err) { | ||||
| return $err; | return $err; | ||||
| } | } | ||||
| $dump = Filesystem::readFile($tmp); | $dump = Filesystem::readFile($tmp); | ||||
| $dump = str_replace( | $dump = str_replace( | ||||
| $namespace, | $namespace, | ||||
| ▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines | |||||