Differential D20572 Diff 49109 src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | $this | ||||
)); | )); | ||||
} | } | ||||
protected function isReadOnlyWorkflow() { | protected function isReadOnlyWorkflow() { | ||||
return true; | return true; | ||||
} | } | ||||
public function didExecute(PhutilArgumentParser $args) { | public function didExecute(PhutilArgumentParser $args) { | ||||
$output_file = $args->getArg('output'); | |||||
$is_compress = $args->getArg('compress'); | |||||
$is_overwrite = $args->getArg('overwrite'); | |||||
if ($is_compress) { | |||||
if ($output_file === null) { | |||||
throw new PhutilArgumentUsageException( | |||||
pht( | |||||
'The "--compress" flag can only be used alongside "--output".')); | |||||
} | |||||
if (!function_exists('gzopen')) { | |||||
throw new PhutilArgumentUsageException( | |||||
pht( | |||||
'The "--compress" flag requires the PHP "zlib" extension, but '. | |||||
'that extension is not available. Install the extension or '. | |||||
'omit the "--compress" option.')); | |||||
} | |||||
} | |||||
if ($is_overwrite) { | |||||
if ($output_file === null) { | |||||
throw new PhutilArgumentUsageException( | |||||
pht( | |||||
'The "--overwrite" flag can only be used alongside "--output".')); | |||||
} | |||||
} | |||||
if ($output_file !== null) { | |||||
if (Filesystem::pathExists($output_file)) { | |||||
if (!$is_overwrite) { | |||||
throw new PhutilArgumentUsageException( | |||||
pht( | |||||
'Output file "%s" already exists. Use "--overwrite" '. | |||||
'to overwrite.', | |||||
$output_file)); | |||||
} | |||||
} | |||||
} | |||||
$api = $this->getSingleAPI(); | $api = $this->getSingleAPI(); | ||||
$patches = $this->getPatches(); | $patches = $this->getPatches(); | ||||
$console = PhutilConsole::getConsole(); | |||||
$with_indexes = !$args->getArg('no-indexes'); | $with_indexes = !$args->getArg('no-indexes'); | ||||
$applied = $api->getAppliedPatches(); | $applied = $api->getAppliedPatches(); | ||||
if ($applied === null) { | if ($applied === null) { | ||||
$namespace = $api->getNamespace(); | throw new PhutilArgumentUsageException( | ||||
$console->writeErr( | |||||
pht( | pht( | ||||
'**Storage Not Initialized**: There is no database storage '. | 'There is no database storage initialized in the current storage '. | ||||
'initialized in this storage namespace ("%s"). Use '. | 'namespace ("%s"). Use "bin/storage upgrade" to initialize '. | ||||
'**%s** to initialize storage.', | 'storage or use "--namespace" to choose a different namespace.', | ||||
$namespace, | $api->getNamespace())); | ||||
'./bin/storage upgrade')); | |||||
return 1; | |||||
} | } | ||||
$ref = $api->getRef(); | $ref = $api->getRef(); | ||||
$ref_key = $ref->getRefKey(); | $ref_key = $ref->getRefKey(); | ||||
$schemata_query = id(new PhabricatorConfigSchemaQuery()) | $schemata_query = id(new PhabricatorConfigSchemaQuery()) | ||||
->setAPIs(array($api)) | ->setAPIs(array($api)) | ||||
->setRefs(array($ref)); | ->setRefs(array($ref)); | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | public function didExecute(PhutilArgumentParser $args) { | ||||
$password = $api->getPassword(); | $password = $api->getPassword(); | ||||
if ($password) { | if ($password) { | ||||
if (strlen($password->openEnvelope())) { | if (strlen($password->openEnvelope())) { | ||||
$has_password = true; | $has_password = true; | ||||
} | } | ||||
} | } | ||||
$output_file = $args->getArg('output'); | |||||
$is_compress = $args->getArg('compress'); | |||||
$is_overwrite = $args->getArg('overwrite'); | |||||
if ($is_compress) { | |||||
if ($output_file === null) { | |||||
throw new PhutilArgumentUsageException( | |||||
pht( | |||||
'The "--compress" flag can only be used alongside "--output".')); | |||||
} | |||||
} | |||||
if ($is_overwrite) { | |||||
if ($output_file === null) { | |||||
throw new PhutilArgumentUsageException( | |||||
pht( | |||||
'The "--overwrite" flag can only be used alongside "--output".')); | |||||
} | |||||
} | |||||
if ($output_file !== null) { | |||||
if (Filesystem::pathExists($output_file)) { | |||||
if (!$is_overwrite) { | |||||
throw new PhutilArgumentUsageException( | |||||
pht( | |||||
'Output file "%s" already exists. Use "--overwrite" '. | |||||
'to overwrite.', | |||||
$output_file)); | |||||
} | |||||
} | |||||
} | |||||
$argv = array(); | $argv = array(); | ||||
$argv[] = '--hex-blob'; | $argv[] = '--hex-blob'; | ||||
$argv[] = '--single-transaction'; | $argv[] = '--single-transaction'; | ||||
$argv[] = '--default-character-set=utf8'; | $argv[] = '--default-character-set=utf8'; | ||||
if ($args->getArg('for-replica')) { | if ($args->getArg('for-replica')) { | ||||
$argv[] = '--master-data'; | $argv[] = '--master-data'; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |