Skip to content

Commit

Permalink
Remove —sanitize from sql-sync.
Browse files Browse the repository at this point in the history
Now, you have to run sql-sanitize as a second command after running sql-sync.
  • Loading branch information
weitzman committed Aug 6, 2017
1 parent 5034d67 commit 19543e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
17 changes: 1 addition & 16 deletions src/Commands/sql/SqlSyncCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ class SqlSyncCommands extends DrushCommands
* @option create-db Create a new database before importing the database dump on the target machine.
* @option db-su Account to use when creating a new database (e.g. root).
* @option db-su-pw Password for the db-su account.
* # We cannot list sql-sanitize below since it bootstraps higher - to FULL.
* @allow-additional-options
* @option sanitize Obscure email addresses and reset passwords in the user table post-sync.
* @option confirm-sanitizations Prompt yes/no after importing the database, but before running the sanitizations.
* @usage drush sql-sync @source @target
* Copy the database from the site with the alias 'source' to the site with the alias 'target'.
* @usage drush sql-sync prod dev
* Copy the database from the site in /sites/prod to the site in /sites/dev (multisite installation).
* @topics docs-aliases,docs-policy,docs-example-sync-via-http
* @complete \Drush\Commands\CompletionCommands::completeSiteAliases
*/
public function sqlsync($source, $destination, $options = ['no-dump' => false, 'no-sync' => false, 'runner' => null, 'create-db' => false, 'db-su' => null, 'db-su-pw' => null, 'sanitize' => false, 'confirm-sanitizations' => false, 'target-dump' => null, 'source-dump' => true])
public function sqlsync($source, $destination, $options = ['no-dump' => false, 'no-sync' => false, 'runner' => null, 'create-db' => false, 'db-su' => null, 'db-su-pw' => null, 'target-dump' => null, 'source-dump' => true])
{
$source_record = drush_sitealias_get_record($source);
$destination_record = drush_sitealias_get_record($destination);
Expand Down Expand Up @@ -131,16 +127,6 @@ public function sqlsync($source, $destination, $options = ['no-dump' => false, '
// An error was already logged.
return false;
}

// Run Sanitize if needed.
$sanitize_options = $global_options;
if ($options['sanitize']) {
$this->logger()->notice(dt('Starting to sanitize target database on Destination.'));
$return = drush_invoke_process($destination, 'sql-sanitize', array(), $sanitize_options, $backend_options);
if ($return['error_status']) {
throw new \Exception(dt('sql-sanitize failed.'));
}
}
}

/**
Expand Down Expand Up @@ -208,7 +194,6 @@ public function validate(CommandData $commandData)
'!source' => $txt_source,
'!target' => $txt_destination
)));
// @todo Move sanitization prompts to here. They currently show much later.
if (!$this->io()->confirm(dt('Do you really want to continue?'))) {
throw new UserAbortException();
}
Expand Down
5 changes: 2 additions & 3 deletions tests/sqlSyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ public function localSqlSync() {

// Copy stage to dev with --sanitize.
$sync_options = array(
'sanitize' => NULL,
'yes' => NULL,
// Test wildcards expansion from within sql-sync. Also avoid D8 persistent entity cache.
'structure-tables-list' => 'cache,cache*',
);
$this->drush('sql-sync', array('@stage', '@dev'), $sync_options);
$this->drush('sql-sanitize', [], ['yes' => NULL], '@dev');

// Confirm that the sample user is unchanged on the staging site
$this->drush('user-information', array($name), $options + array('format' => 'csv', 'include-field-labels' => 0, 'strict' => 0), '@stage');
Expand All @@ -89,13 +89,12 @@ public function localSqlSync() {

// Copy stage to dev with --sanitize and a fixed sanitized email
$sync_options = array(
'sanitize' => NULL,
'yes' => NULL,
'sanitize-email' => '[email protected]',
// Test wildcards expansion from within sql-sync. Also avoid D8 persistent entity cache.
'structure-tables-list' => 'cache,cache*',
);
$this->drush('sql-sync', array('@stage', '@dev'), $sync_options);
$this->drush('sql-sanitize', [], ['yes' => NULL, 'sanitize-email' => '[email protected]'], '@dev');

$options = array(
'root' => $this->webroot(),
Expand Down

0 comments on commit 19543e5

Please sign in to comment.