acquia / cli

Acquia CLI
GNU General Public License v2.0
42 stars 47 forks source link

CLI-1225: The pull:database command fails silently if pv is not installed. #1640

Closed mdlutz24 closed 9 months ago

mdlutz24 commented 9 months ago

Describe the bug The pull:database command fails silently if pv is not installed.

To Reproduce Steps to reproduce the behavior: On a system without pv installed set the appropriate ACLIDB**** environmental variables and execute an acli pull:database request. See the database downloaded and the command appear to succeed. Open the database and see that it is empty.

Expected behavior The database should be populated from the specified environment

Additional context Relevant code from Acquia\Cli\Command\Pull\PullCommandBase::importDatabaseDump:

if ($this->localMachineHelper->commandExists('pv')) {
      $command = "pv $localDumpFilepath --bytes --rate | gunzip | MYSQL_PWD=$dbPassword mysql --host=$dbHost --user=$dbUser $dbName";
    }
    else {
      $this->io->warning('Install `pv` to see progress bar');
      $command = "gunzip $localDumpFilepath | MYSQL_PWD=$dbPassword mysql --host=$dbHost --user=$dbUser $dbName";
    }

If pv is installed, the zipped database dump is passed to gunzip via stdin, which then passes the uncompressed dump to mysql via stdout If pv is NOT installed, the zipped database dump is passed to gunzip as a file, which unzips it in place and nothing is sent to stdout, and mysql recieves no commands from stdin to execute. Since no commands were passed, nothing is done and mysql happily exits, having done everything it was asked to do. This seems to have been introduced in commit 7342d40c when pv was made optional for the pull:database command