From 19543e5b5ebecc68f71b782fa3f57d954af4632f Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sun, 6 Aug 2017 07:58:23 -0400 Subject: [PATCH] =?UTF-8?q?Remove=20=E2=80=94sanitize=20from=20sql-sync.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now, you have to run sql-sanitize as a second command after running sql-sync. --- src/Commands/sql/SqlSyncCommands.php | 17 +---------------- tests/sqlSyncTest.php | 5 ++--- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/Commands/sql/SqlSyncCommands.php b/src/Commands/sql/SqlSyncCommands.php index 1bd798b719..c781e4820e 100644 --- a/src/Commands/sql/SqlSyncCommands.php +++ b/src/Commands/sql/SqlSyncCommands.php @@ -24,10 +24,6 @@ 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 @@ -35,7 +31,7 @@ class SqlSyncCommands extends DrushCommands * @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); @@ -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.')); - } - } } /** @@ -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(); } diff --git a/tests/sqlSyncTest.php b/tests/sqlSyncTest.php index b8b2ee71a3..cca6b3d6d7 100644 --- a/tests/sqlSyncTest.php +++ b/tests/sqlSyncTest.php @@ -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'); @@ -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' => 'user@mysite.org', // 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' => 'user@mysite.org'], '@dev'); $options = array( 'root' => $this->webroot(),