Skip to content

Commit 0dd2f02

Browse files
authored
Vastly improve return handling from older versions of Drush when doin… (#3784)
* Vastly improve return handling from older versions of Drush when doing a sql:dump as part of a sql:sync
1 parent 32a712f commit 0dd2f02

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/Commands/sql/SqlSyncCommands.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,25 @@ public function dump($options, $global_options, $sourceRecord)
146146
if (Drush::simulate()) {
147147
$source_dump_path = '/simulated/path/to/dump.tgz';
148148
} else {
149-
try {
150-
// First try a Drush 9.6+ return format.
151-
$json = $process->getOutputAsJson();
149+
// First try a Drush 9.6+ return format.
150+
$json = $process->getOutputAsJson();
151+
if (!empty($json['path'])) {
152152
$source_dump_path = $json['path'];
153-
} catch (\Exception $e) {
153+
} else {
154154
// Next, try 9.5- format.
155155
$return = drush_backend_parse_output($process->getOutput());
156-
if ($return['error_status'] || empty($return['object'])) {
157-
// Neither attempt worked.
158-
throw new \Exception(dt('The Drush sql:dump command did not report the path to the dump file.'));
159-
} else {
156+
if (!$return['error_status'] || !empty($return['object'])) {
160157
$source_dump_path = $return['object'];
161158
}
162159
}
163160
}
164161
} else {
165162
$source_dump_path = $options['source-dump'];
166163
}
164+
165+
if (empty($source_dump_path)) {
166+
throw new \Exception(dt('The Drush sql:dump command did not report the path to the dump file.'));
167+
}
167168
return $source_dump_path;
168169
}
169170

0 commit comments

Comments
 (0)