Skip to content

Commit 4e795b8

Browse files
authored
CLI-1665: pull:db errors (#1929)
1 parent c78ef49 commit 4e795b8

3 files changed

Lines changed: 3 additions & 15 deletions

File tree

src/Command/Pull/PullCommandBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ private function importDatabaseDump(string $localDumpFilepath, string $dbHost, s
486486
'mysql',
487487
]);
488488
if ($this->localMachineHelper->commandExists('pv')) {
489-
$command = 'pv "${:LOCAL_DUMP_FILEPATH}" --bytes --rate | gunzip | MYSQL_PWD="${:MYSQL_PASSWORD}" mysql --host="${:MYSQL_HOST}" --user="${:MYSQL_USER}" "${:MYSQL_DATABASE}""';
489+
$command = 'pv "${:LOCAL_DUMP_FILEPATH}" --bytes --rate | gunzip | MYSQL_PWD="${:MYSQL_PASSWORD}" mysql --host="${:MYSQL_HOST}" --user="${:MYSQL_USER}" "${:MYSQL_DATABASE}"';
490490
} else {
491491
$this->io->warning('Install `pv` to see progress bar');
492492
$command = 'gunzip -c "${:LOCAL_DUMP_FILEPATH}" | MYSQL_PWD="${:MYSQL_PASSWORD}" mysql --host="${:MYSQL_HOST}" --user="${:MYSQL_USER}" "${:MYSQL_DATABASE}"';

tests/phpunit/src/CommandTestBase.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -441,19 +441,7 @@ protected function mockCreateMySqlDumpOnLocal(ObjectProphecy $localMachineHelper
441441
$process = $this->mockProcess();
442442
$process->getOutput()->willReturn('');
443443
if ($pv) {
444-
$command = 'bash -c "set -o pipefail; MYSQL_PWD="${:MYSQL_PASSWORD}" mysqldump --host="${:MYSQL_HOST}" --user="${:MYSQL_USER}" "${:MYSQL_DATABASE}" | pv --rate --bytes | gzip -9 > "${:LOCAL_FILEPATH}""';
445-
} else {
446-
$command = 'bash -c "set -o pipefail; MYSQL_PWD="${:MYSQL_PASSWORD}" mysqldump --host="${:MYSQL_HOST}" --user="${:MYSQL_USER}" "${:MYSQL_DATABASE}" | gzip -9 > "${:LOCAL_FILEPATH}""';
447-
}
448-
$env = [
449-
'LOCAL_FILEPATH' => sys_get_temp_dir() . '/acli-mysql-dump-drupal.sql.gz',
450-
'MYSQL_DATABASE' => 'drupal',
451-
'MYSQL_HOST' => 'localhost',
452-
'MYSQL_PASSWORD' => 'drupal',
453-
'MYSQL_USER' => 'drupal',
454-
];
455-
if ($pv) {
456-
$localMachineHelper->executeFromCmd(Argument::containingString('pv --rate --bytes'), Argument::any(), null, $printOutput, null, Argument::that(function ($env) {
444+
$localMachineHelper->executeFromCmd(Argument::containingString('pv --rate --bytes'), Argument::any(), null, $printOutput, null, Argument::that(static function ($env) {
457445
return is_array($env) && array_key_exists('LOCAL_FILEPATH', $env);
458446
}))
459447
->willReturn($process->reveal())

tests/phpunit/src/Commands/Pull/PullCommandTestBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ protected function mockExecuteMySqlImport(
310310
$this->mockExecutePvExists($localMachineHelper, $pvExists);
311311
$process = $this->mockProcess($success);
312312
$filePath = Path::join(sys_get_temp_dir(), "$env-$dbName-$dbMachineName-$createdAt.sql.gz");
313-
$command = $pvExists ? 'pv "${:LOCAL_DUMP_FILEPATH}" --bytes --rate | gunzip | MYSQL_PWD="${:MYSQL_PASSWORD}" mysql --host="${:MYSQL_HOST}" --user="${:MYSQL_USER}" "${:MYSQL_DATABASE}""' : 'gunzip -c "${:LOCAL_DUMP_FILEPATH}" | MYSQL_PWD="${:MYSQL_PASSWORD}" mysql --host="${:MYSQL_HOST}" --user="${:MYSQL_USER}" "${:MYSQL_DATABASE}"';
313+
$command = $pvExists ? 'pv "${:LOCAL_DUMP_FILEPATH}" --bytes --rate | gunzip | MYSQL_PWD="${:MYSQL_PASSWORD}" mysql --host="${:MYSQL_HOST}" --user="${:MYSQL_USER}" "${:MYSQL_DATABASE}"' : 'gunzip -c "${:LOCAL_DUMP_FILEPATH}" | MYSQL_PWD="${:MYSQL_PASSWORD}" mysql --host="${:MYSQL_HOST}" --user="${:MYSQL_USER}" "${:MYSQL_DATABASE}"';
314314
$expectedEnv = [
315315
'LOCAL_DUMP_FILEPATH' => $filePath,
316316
'MYSQL_DATABASE' => $localDbName,

0 commit comments

Comments
 (0)