From aa2612bd45bc2c7f71088551bf9785dc0d368ee5 Mon Sep 17 00:00:00 2001 From: Malcolm Young Date: Tue, 4 Dec 2018 17:47:39 +0000 Subject: [PATCH 01/20] Issue #3017760: initial auto-generation of drush 9 commands --- composer.json | 8 +++- drush.services.yml | 5 +++ src/Commands/DatabaseSanitizeCommands.php | 54 +++++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 drush.services.yml create mode 100644 src/Commands/DatabaseSanitizeCommands.php diff --git a/composer.json b/composer.json index 9cb4818..16ff89a 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,11 @@ "require": { "edisonlabs/merge-yaml": "~1" }, - "require-dev": { - "drush/drush": "~8.1.17" + "extra": { + "drush": { + "services": { + "drush.services.yml": "^9" + } + } } } diff --git a/drush.services.yml b/drush.services.yml new file mode 100644 index 0000000..64cad3e --- /dev/null +++ b/drush.services.yml @@ -0,0 +1,5 @@ +services: + database_sanitize.commands: + class: \Drupal\database_sanitize\Commands\DatabaseSanitizeCommands + tags: + - { name: drush.command } diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php new file mode 100644 index 0000000..e01174d --- /dev/null +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -0,0 +1,54 @@ + null, 'list' => null]) { + // See bottom of https://weitzman.github.io/blog/port-to-drush9 for details on what to change when porting a + // legacy command. + } + + /** + * Generates a database.sanitize.yml file for tables not specified on sanitize YML files. + * + * @param array $options An associative array of options whose values come from cli, aliases, config, etc. + * @option file + * The full path to a sanitize YML file. + * @option machine-name + * The machine name to export the tables under. + * + * @command db:sanitize-generate + * @aliases dbsg,db-sanitize-generate + */ + public function sanitizeGenerate(array $options = ['file' => null, 'machine-name' => null]) { + // See bottom of https://weitzman.github.io/blog/port-to-drush9 for details on what to change when porting a + // legacy command. + } + +} From 4dbc823e92c06ce91616ed52ff0db9eb9c46409b Mon Sep 17 00:00:00 2001 From: Malcolm Young Date: Tue, 4 Dec 2018 17:53:28 +0000 Subject: [PATCH 02/20] fix coding standards issues mentioned by codesniffer --- src/Commands/DatabaseSanitizeCommands.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index e01174d..d6c9c33 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -20,7 +20,9 @@ class DatabaseSanitizeCommands extends DrushCommands { /** * Compares existing database.sanitize.yml files on the site installation against existing database tables. * - * @param array $options An associative array of options whose values come from cli, aliases, config, etc. + * @param array $options + * An associative array of options whose values come from cli, aliases, config, etc. + * * @option file * The full path to a sanitize YML file. * @option list @@ -29,7 +31,7 @@ class DatabaseSanitizeCommands extends DrushCommands { * @command db:sanitize-analyze * @aliases dbsa,db-sanitize-analyze */ - public function sanitizeAnalyze(array $options = ['file' => null, 'list' => null]) { + public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL]) { // See bottom of https://weitzman.github.io/blog/port-to-drush9 for details on what to change when porting a // legacy command. } @@ -37,7 +39,9 @@ public function sanitizeAnalyze(array $options = ['file' => null, 'list' => null /** * Generates a database.sanitize.yml file for tables not specified on sanitize YML files. * - * @param array $options An associative array of options whose values come from cli, aliases, config, etc. + * @param array $options + * An associative array of options whose values come from cli, aliases, config, etc. + * * @option file * The full path to a sanitize YML file. * @option machine-name @@ -46,7 +50,7 @@ public function sanitizeAnalyze(array $options = ['file' => null, 'list' => null * @command db:sanitize-generate * @aliases dbsg,db-sanitize-generate */ - public function sanitizeGenerate(array $options = ['file' => null, 'machine-name' => null]) { + public function sanitizeGenerate(array $options = ['file' => NULL, 'machine-name' => NULL]) { // See bottom of https://weitzman.github.io/blog/port-to-drush9 for details on what to change when porting a // legacy command. } From e55727b66ca1c7004e213546a07f09f1ae994817 Mon Sep 17 00:00:00 2001 From: Malcolm Young Date: Tue, 4 Dec 2018 18:02:35 +0000 Subject: [PATCH 03/20] basic conversion of dbsa command --- src/Commands/DatabaseSanitizeCommands.php | 29 +++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index d6c9c33..30376ea 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -18,10 +18,12 @@ class DatabaseSanitizeCommands extends DrushCommands { /** - * Compares existing database.sanitize.yml files on the site installation against existing database tables. + * Compares existing database.sanitize.yml files on the site installation + * against existing database tables. * * @param array $options - * An associative array of options whose values come from cli, aliases, config, etc. + * An associative array of options whose values come from cli, aliases, + * config, etc. * * @option file * The full path to a sanitize YML file. @@ -30,10 +32,33 @@ class DatabaseSanitizeCommands extends DrushCommands { * * @command db:sanitize-analyze * @aliases dbsa,db-sanitize-analyze + * @return void + * @throws \Exception */ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL]) { // See bottom of https://weitzman.github.io/blog/port-to-drush9 for details on what to change when porting a // legacy command. + if (empty($options['file'])) { + $options['file'] = $this->io()->ask('Please provide the full path to a sanitize YML file'); + } + + $file = $options['file']; + if (!file_exists($file)) { + throw new \Exception(dt('File @file does not exist', ['@file' => $file])); + } + + $missing_tables = \Drupal::service('database_sanitize')->getUnspecifiedTables($file); + + if (!$missing_tables) { + $this->logger()->info(dt('All database tables are already specified in sanitize YML files'), 'ok'); + return; + } + + $this->logger()->warning(dt('There are @count tables not defined on sanitize YML files', ['@count' => count($missing_tables)])); + + if (!empty($options['list'])) { + $this->logger()->warning(implode("\n", $missing_tables)); + } } /** From c084954111c201441068d63d1313011a3cf016ba Mon Sep 17 00:00:00 2001 From: Malcolm Young Date: Tue, 4 Dec 2018 18:04:01 +0000 Subject: [PATCH 04/20] basic conversion of dbsg command --- src/Commands/DatabaseSanitizeCommands.php | 28 ++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index 30376ea..4527fc3 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -76,8 +76,30 @@ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL * @aliases dbsg,db-sanitize-generate */ public function sanitizeGenerate(array $options = ['file' => NULL, 'machine-name' => NULL]) { - // See bottom of https://weitzman.github.io/blog/port-to-drush9 for details on what to change when porting a - // legacy command. - } + $machine_name = $options['machine-name']; + if (empty($machine_name)) { + throw new \Exception(dt('You must specify a machine-name')); + } + + $yml_file_path = $options['file']; + $missing_tables = \Drupal::service('database_sanitize')->getUnspecifiedTables($yml_file_path); + if (!$missing_tables) { + $this->logger()->info(dt('All database tables are already specified in sanitize YML files'), 'ok'); + return; + } + + $content = [ + 'sanitize' => [ + $machine_name => [], + ], + ]; + foreach ($missing_tables as $table) { + $content['sanitize'][$machine_name][$table] = [ + 'description' => "Sanitization entry for {$table}. Generated by drush db-sanitize-generate.", + 'query' => "TRUNCATE TABLE {$table}", + ]; + } + + return $content; } } From a6d599589e8ac2fd1194c6f8da25f21a70788f4a Mon Sep 17 00:00:00 2001 From: Malcolm Young Date: Tue, 4 Dec 2018 18:08:38 +0000 Subject: [PATCH 05/20] coding standards fixes --- src/Commands/DatabaseSanitizeCommands.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index 4527fc3..75aae77 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -18,6 +18,8 @@ class DatabaseSanitizeCommands extends DrushCommands { /** + * Analyze existing yml files. + * * Compares existing database.sanitize.yml files on the site installation * against existing database tables. * @@ -32,12 +34,10 @@ class DatabaseSanitizeCommands extends DrushCommands { * * @command db:sanitize-analyze * @aliases dbsa,db-sanitize-analyze - * @return void + * * @throws \Exception */ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL]) { - // See bottom of https://weitzman.github.io/blog/port-to-drush9 for details on what to change when porting a - // legacy command. if (empty($options['file'])) { $options['file'] = $this->io()->ask('Please provide the full path to a sanitize YML file'); } @@ -62,10 +62,14 @@ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL } /** - * Generates a database.sanitize.yml file for tables not specified on sanitize YML files. + * Generates a database.sanitize.yml file. + * + * Generate database.sanitize.yml file for tables not specified on sanitize + * YML files. * * @param array $options - * An associative array of options whose values come from cli, aliases, config, etc. + * An associative array of options whose values come from cli, aliases, + * config, etc. * * @option file * The full path to a sanitize YML file. @@ -74,6 +78,9 @@ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL * * @command db:sanitize-generate * @aliases dbsg,db-sanitize-generate + * + * @return array|void + * @throws \Exception */ public function sanitizeGenerate(array $options = ['file' => NULL, 'machine-name' => NULL]) { $machine_name = $options['machine-name']; @@ -100,6 +107,7 @@ public function sanitizeGenerate(array $options = ['file' => NULL, 'machine-name ]; } - return $content; } + return $content; + } } From e0085140de02874795236dbf9c73db198414c42e Mon Sep 17 00:00:00 2001 From: Malcolm Young Date: Tue, 4 Dec 2018 18:19:53 +0000 Subject: [PATCH 06/20] coding standards fixes --- src/Commands/DatabaseSanitizeCommands.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index 75aae77..627c909 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -79,7 +79,9 @@ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL * @command db:sanitize-generate * @aliases dbsg,db-sanitize-generate * - * @return array|void + * @return array + * Array of sanitization entries - TODO: more info. + * * @throws \Exception */ public function sanitizeGenerate(array $options = ['file' => NULL, 'machine-name' => NULL]) { @@ -92,7 +94,7 @@ public function sanitizeGenerate(array $options = ['file' => NULL, 'machine-name $missing_tables = \Drupal::service('database_sanitize')->getUnspecifiedTables($yml_file_path); if (!$missing_tables) { $this->logger()->info(dt('All database tables are already specified in sanitize YML files'), 'ok'); - return; + return []; } $content = [ From faf216e81d5c35253c475aec85062e9c9133673b Mon Sep 17 00:00:00 2001 From: Malcolm Young Date: Tue, 4 Dec 2018 18:25:10 +0000 Subject: [PATCH 07/20] get options from I/O --- src/Commands/DatabaseSanitizeCommands.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index 627c909..97db556 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -50,7 +50,7 @@ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL $missing_tables = \Drupal::service('database_sanitize')->getUnspecifiedTables($file); if (!$missing_tables) { - $this->logger()->info(dt('All database tables are already specified in sanitize YML files'), 'ok'); + $this->logger()->info(dt('All database tables are already specified in sanitize YML files')); return; } @@ -87,13 +87,17 @@ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL public function sanitizeGenerate(array $options = ['file' => NULL, 'machine-name' => NULL]) { $machine_name = $options['machine-name']; if (empty($machine_name)) { - throw new \Exception(dt('You must specify a machine-name')); + $machine_name = $this->io()->ask('Please provide the machine name to export the tables under'); + } + + if (empty($options['file'])) { + $options['file'] = $this->io()->ask('Please provide the full path to a sanitize YML file'); } $yml_file_path = $options['file']; $missing_tables = \Drupal::service('database_sanitize')->getUnspecifiedTables($yml_file_path); if (!$missing_tables) { - $this->logger()->info(dt('All database tables are already specified in sanitize YML files'), 'ok'); + $this->logger()->info(dt('All database tables are already specified in sanitize YML files')); return []; } From 1b3157c0366fe35dff41bb5a37b34a27c7862077 Mon Sep 17 00:00:00 2001 From: Malcolm Young Date: Tue, 4 Dec 2018 18:26:17 +0000 Subject: [PATCH 08/20] add drush back in dev dependencies --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 16ff89a..aed0514 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,9 @@ "require": { "edisonlabs/merge-yaml": "~1" }, + "require-dev": { + "drush/drush": "~8.1.17" + }, "extra": { "drush": { "services": { From 495b9e0c9040428a7d249d87dfe8934aa4ef6d47 Mon Sep 17 00:00:00 2001 From: Malcolm Young Date: Tue, 4 Dec 2018 20:13:21 +0000 Subject: [PATCH 09/20] make file optional in analyze command --- src/Commands/DatabaseSanitizeCommands.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index 97db556..998a75c 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -38,12 +38,8 @@ class DatabaseSanitizeCommands extends DrushCommands { * @throws \Exception */ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL]) { - if (empty($options['file'])) { - $options['file'] = $this->io()->ask('Please provide the full path to a sanitize YML file'); - } - $file = $options['file']; - if (!file_exists($file)) { + if (!empty($file) && !file_exists($file)) { throw new \Exception(dt('File @file does not exist', ['@file' => $file])); } From e6ef174ab359b114bf3f222ee2340b306e6b6004 Mon Sep 17 00:00:00 2001 From: Vijaya Chandran Mani Date: Thu, 13 Dec 2018 12:33:09 +0000 Subject: [PATCH 10/20] #3017760 - Support drush 9 - Address review comments from #9 --- drush.services.yml | 1 + src/Commands/DatabaseSanitizeCommands.php | 40 +++++++++++++---------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/drush.services.yml b/drush.services.yml index 64cad3e..acaa9fb 100644 --- a/drush.services.yml +++ b/drush.services.yml @@ -1,5 +1,6 @@ services: database_sanitize.commands: class: \Drupal\database_sanitize\Commands\DatabaseSanitizeCommands + arguments: ['@database_sanitize'] tags: - { name: drush.command } diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index 998a75c..77b0362 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -2,21 +2,30 @@ namespace Drupal\database_sanitize\Commands; +use Drupal\database_sanitize\DatabaseSanitize; use Drush\Commands\DrushCommands; /** - * A Drush commandfile. - * - * In addition to this file, you need a drush.services.yml - * in root of your module, and a composer.json file that provides the name - * of the services file to use. - * - * See these files for an example of injecting Drupal services: - * - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php - * - http://cgit.drupalcode.org/devel/tree/drush.services.yml + * Class DatabaseSanitizeCommands */ class DatabaseSanitizeCommands extends DrushCommands { + /** + * The sanitizer service instance. + * + * @var \Drupal\database_sanitize\DatabaseSanitize + */ + protected $sanitizer; + + /** + * DatabaseSanitizeCommands constructor. + * + * @param \Drupal\database_sanitize\DatabaseSanitize $sanitizer + */ + public function __construct(DatabaseSanitize $sanitizer) { + $this->sanitizer = $sanitizer; + } + /** * Analyze existing yml files. * @@ -37,13 +46,13 @@ class DatabaseSanitizeCommands extends DrushCommands { * * @throws \Exception */ - public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL]) { + public function analyze(array $options = ['file' => NULL, 'list' => NULL]) { $file = $options['file']; if (!empty($file) && !file_exists($file)) { throw new \Exception(dt('File @file does not exist', ['@file' => $file])); } - $missing_tables = \Drupal::service('database_sanitize')->getUnspecifiedTables($file); + $missing_tables = $this->sanitizer->getUnspecifiedTables($file); if (!$missing_tables) { $this->logger()->info(dt('All database tables are already specified in sanitize YML files')); @@ -58,10 +67,7 @@ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL } /** - * Generates a database.sanitize.yml file. - * - * Generate database.sanitize.yml file for tables not specified on sanitize - * YML files. + * Generate Sanitization entries. * * @param array $options * An associative array of options whose values come from cli, aliases, @@ -80,7 +86,7 @@ public function sanitizeAnalyze(array $options = ['file' => NULL, 'list' => NULL * * @throws \Exception */ - public function sanitizeGenerate(array $options = ['file' => NULL, 'machine-name' => NULL]) { + public function generate(array $options = ['file' => NULL, 'machine-name' => NULL]) { $machine_name = $options['machine-name']; if (empty($machine_name)) { $machine_name = $this->io()->ask('Please provide the machine name to export the tables under'); @@ -91,7 +97,7 @@ public function sanitizeGenerate(array $options = ['file' => NULL, 'machine-name } $yml_file_path = $options['file']; - $missing_tables = \Drupal::service('database_sanitize')->getUnspecifiedTables($yml_file_path); + $missing_tables = $this->sanitizer->getUnspecifiedTables($yml_file_path); if (!$missing_tables) { $this->logger()->info(dt('All database tables are already specified in sanitize YML files')); return []; From 8a3196f2c36a839947443fc832a7a42d44eba978 Mon Sep 17 00:00:00 2001 From: Manuel Garcia Date: Thu, 13 Dec 2018 18:32:40 +0000 Subject: [PATCH 11/20] Docblock update suggested by @manuee Co-Authored-By: vijaycs85 --- src/Commands/DatabaseSanitizeCommands.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index 77b0362..cb02ece 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -6,7 +6,7 @@ use Drush\Commands\DrushCommands; /** - * Class DatabaseSanitizeCommands + * Drush commands for Database Sanitize. */ class DatabaseSanitizeCommands extends DrushCommands { From 59081d1678bb9eb523211a8927316b8c09244b87 Mon Sep 17 00:00:00 2001 From: Manuel Garcia Date: Thu, 13 Dec 2018 18:33:01 +0000 Subject: [PATCH 12/20] Docblock update. Co-Authored-By: vijaycs85 --- src/Commands/DatabaseSanitizeCommands.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index cb02ece..09af7bf 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -67,7 +67,7 @@ public function analyze(array $options = ['file' => NULL, 'list' => NULL]) { } /** - * Generate Sanitization entries. + * Generates Sanitization entries for tables not specified on sanitize YML files.. * * @param array $options * An associative array of options whose values come from cli, aliases, From 5e2aec7c1b392bc0691f9bd997badb05846f3da6 Mon Sep 17 00:00:00 2001 From: Suzy Masri Date: Thu, 4 Jun 2020 16:55:15 +0300 Subject: [PATCH 13/20] Bumped Drush to 10.2.2 + Upgraded merge-yaml to 2.0.0-alpha1 --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index aed0514..4593f4c 100644 --- a/composer.json +++ b/composer.json @@ -5,15 +5,15 @@ "type": "drupal-module", "minimum-stability": "dev", "require": { - "edisonlabs/merge-yaml": "~1" + "edisonlabs/merge-yaml": "2.0.0-alpha1" }, "require-dev": { - "drush/drush": "~8.1.17" + "drush/drush": "~10.2.2" }, "extra": { "drush": { "services": { - "drush.services.yml": "^9" + "drush.services.yml": "^10" } } } From cfee75eb53d3e1466cd4735277f04c10939256fc Mon Sep 17 00:00:00 2001 From: Suzy Masri Date: Thu, 18 Jun 2020 21:42:43 +0300 Subject: [PATCH 14/20] Testing Drush --- .travis.yml | 5 +- vendor/drush/drush/.travis.yml | 120 +++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 vendor/drush/drush/.travis.yml diff --git a/.travis.yml b/.travis.yml index dde9e12..29fd92b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,8 +33,9 @@ install: before_script: - composer install -vvv - - cd "$TRAVIS_BUILD_DIR/vendor/drush/drush"; composer install + - cd "$TRAVIS_BUILD_DIR/vendor/"; git clone --branch 10.2.2 https://github.com/drush-ops/drush.git drush-tests + - cd "$TRAVIS_BUILD_DIR/vendor/drush-tests"; composer install script: - phpcs --standard=Drupal --ignore=vendor/* --warning-severity=0 . - - php "$TRAVIS_BUILD_DIR/vendor/drush/drush/vendor/bin/phpunit" --configuration "$TRAVIS_BUILD_DIR/vendor/drush/drush/tests" "$TRAVIS_BUILD_DIR/drush/tests" + - php "$TRAVIS_BUILD_DIR/vendor/drush-tests/vendor/bin/phpunit" --configuration "$TRAVIS_BUILD_DIR/vendor/drush-tests/tests" "$TRAVIS_BUILD_DIR/drush/tests" diff --git a/vendor/drush/drush/.travis.yml b/vendor/drush/drush/.travis.yml new file mode 100644 index 0000000..609a892 --- /dev/null +++ b/vendor/drush/drush/.travis.yml @@ -0,0 +1,120 @@ +# Configuration file for unit test runner at http://travis-ci.org/#!/drush-ops/drush +branches: + only: + - master + - 8.x + - 7.x + - 6.x + - 5.x + - /^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+.*$/ +language: php + +services: + - mysql + +# Cache Composer & Unish directories. +cache: + directories: + - $HOME/.composer/cache + - /tmp/unish + +# http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/ +sudo: false + +env: + global: + # Github deploy + - secure: VfYokT2CchfuBRJp9/gSwfVGPfsVfkZdDVEuNWEqxww3z4vq+5aLKqoCtPL54E5EIMjhyCE3GVo+biG35Gab1KOVgUs8zD1hAUWA1FPKfMFhoPDfI3ZJC2rX2T1iWK4ZR90pBtcPzS+2OObzTYz8go0PfeSTT6eq69Na1KcNLaE= + - UNISH_NO_TIMEOUTS=y + - UNISH_DB_URL=mysql://root:@127.0.0.1 + +matrix: + include: + # D9.0.x + - php: 7.4 + env: 'UNISH_DRUPAL_MAJOR_VERSION=9 UNISH_DRUPAL_MINOR_VERSION=0.x-dev' + + # D8.9.x + - php: 7.4 + env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=9.x-dev' + + # D8.8.x + - php: 7.3 + env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=8.5' + + # D8.7.x + - php: 7.2 + env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=7.12' + + # D8.6.x + - php: 7.1 + env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=6.18' + + # D8.5.x + - php: 7.1 + env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=5.15' + + # D8.4.x + - php: 7.1 + env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=4.8 PHPUNIT_ARGS=--group=commands' + + # D8.3.x + - php: 7.1 + env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=3.9 PHPUNIT_ARGS=--group=commands' + + # D8.2.x + - php: 7.0 + env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=2.8 PHPUNIT_ARGS=--group=commands' + + # D7 + - php: 7.1 + env: 'UNISH_DRUPAL_MAJOR_VERSION=7' + + # D7 + - php: 5.6 + env: 'UNISH_DRUPAL_MAJOR_VERSION=7' + + # D6 + - php: 7.0 + env: 'UNISH_DRUPAL_MAJOR_VERSION=6' + + # D6 + - php: 5.6 + env: 'UNISH_DRUPAL_MAJOR_VERSION=6' + +before_install: + - echo 'mbstring.http_input = pass' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + - echo 'mbstring.http_output = pass' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + - travis_retry composer selfupdate + +install: travis_retry composer install --no-interaction + +before_script: + - phpenv config-rm xdebug.ini + - echo 'sendmail_path = /bin/true' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + # - echo "sendmail_path='true'" >> `php --ini | grep "Loaded Configuration" | awk '{print $4}'` + - export UNISH_DRUSH="${PWD}/drush" + +script: ${PWD}/unish.sh $PHPUNIT_ARGS + +# Background: https://github.com/drush-ops/drush/pull/1426 +after_success: ${PWD}/tests/testChildren.sh + +before_deploy: + - gem install mime-types -v 2.6.2 # https://github.com/travis-ci/travis-ci/issues/5145 + - curl -LSs https://box-project.github.io/box2/installer.php | php + - composer install --prefer-dist --no-dev --optimize-autoloader --no-interaction + - php box.phar build + - test $TRAVIS_TAG=true && mkdir s3-stable && cp drush.phar s3-stable/drush.phar + - test $TRAVIS_BRANCH=master && mkdir s3-unstable && cp drush.phar s3-unstable/drush-unstable.phar +deploy: + # http://docs.travis-ci.com/user/deployment/releases/ + - provider: releases + skip_cleanup: true + api_key: + secure: vRtKwJNzm+FXS5VCsaCu5YM4IS02tAdqV4G557HEyVzNgRmSgPWkaHDR/95TnXtZRjmxuTI++rccEj9+jzjknQ9LWkWhl13WiJdZYobnb240f9Ja8g0gs6/r+EEZG2+DTTerK9zicpf51h5hUaE46zObHjSmzIuGxZBO1syDld8= + file: drush.phar + on: + tags: true + repo: drush-ops/drush + all_branches: true From 7e92249293c4611b43581a5a4e06635607bc2a60 Mon Sep 17 00:00:00 2001 From: Suzy Masri Date: Thu, 18 Jun 2020 23:11:22 +0300 Subject: [PATCH 15/20] Removed UNISH_DRUPAL_MAJOR_VERSION --- drush/tests/DatabaseSanitizeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drush/tests/DatabaseSanitizeTest.php b/drush/tests/DatabaseSanitizeTest.php index ff8244f..6cc8538 100644 --- a/drush/tests/DatabaseSanitizeTest.php +++ b/drush/tests/DatabaseSanitizeTest.php @@ -68,7 +68,7 @@ public function setAutoloader() { */ public function setUp() { // Install the standard install profile. - $sites = $this->setUpDrupal(1, TRUE, UNISH_DRUPAL_MAJOR_VERSION); + $sites = $this->setUpDrupal(1, TRUE); $this->webRoot = $this->webroot(); $this->siteOptions = [ 'root' => $this->webRoot, From 7762c40f8db9c1450260cba74996596a4c760aeb Mon Sep 17 00:00:00 2001 From: Suzy Masri Date: Fri, 19 Jun 2020 10:23:29 +0300 Subject: [PATCH 16/20] Teesting autoload real path --- drush/tests/DatabaseSanitizeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drush/tests/DatabaseSanitizeTest.php b/drush/tests/DatabaseSanitizeTest.php index 6cc8538..8b3ff0a 100644 --- a/drush/tests/DatabaseSanitizeTest.php +++ b/drush/tests/DatabaseSanitizeTest.php @@ -56,7 +56,7 @@ class DatabaseSanitizeCase extends CommandUnishTestCase { * This function needs to be called after setUpDrupal(). */ public function setAutoloader() { - $autoloader_real_path = $this->webRoot . '/vendor/composer/autoload_real.php'; + $autoloader_real_path = $this->webRoot . '/../vendor/composer/autoload_real.php'; $autoloader_real_content = file_get_contents($autoloader_real_path); $autoloader_psr4_content = str_replace(' Date: Fri, 19 Jun 2020 10:37:14 +0300 Subject: [PATCH 17/20] Changed MergeYaml version --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4593f4c..5ff06da 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "type": "drupal-module", "minimum-stability": "dev", "require": { - "edisonlabs/merge-yaml": "2.0.0-alpha1" + "edisonlabs/merge-yaml": "~2" }, "require-dev": { "drush/drush": "~10.2.2" @@ -13,7 +13,7 @@ "extra": { "drush": { "services": { - "drush.services.yml": "^10" + "drush.services.yml": "^9 || ^10" } } } From 8a535be9027b0f179dd09ebbd10d4ea79468f3ae Mon Sep 17 00:00:00 2001 From: Suzy Masri Date: Mon, 22 Jun 2020 09:58:18 +0300 Subject: [PATCH 18/20] Unwanted file --- vendor/drush/drush/.travis.yml | 120 --------------------------------- 1 file changed, 120 deletions(-) delete mode 100644 vendor/drush/drush/.travis.yml diff --git a/vendor/drush/drush/.travis.yml b/vendor/drush/drush/.travis.yml deleted file mode 100644 index 609a892..0000000 --- a/vendor/drush/drush/.travis.yml +++ /dev/null @@ -1,120 +0,0 @@ -# Configuration file for unit test runner at http://travis-ci.org/#!/drush-ops/drush -branches: - only: - - master - - 8.x - - 7.x - - 6.x - - 5.x - - /^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+.*$/ -language: php - -services: - - mysql - -# Cache Composer & Unish directories. -cache: - directories: - - $HOME/.composer/cache - - /tmp/unish - -# http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/ -sudo: false - -env: - global: - # Github deploy - - secure: VfYokT2CchfuBRJp9/gSwfVGPfsVfkZdDVEuNWEqxww3z4vq+5aLKqoCtPL54E5EIMjhyCE3GVo+biG35Gab1KOVgUs8zD1hAUWA1FPKfMFhoPDfI3ZJC2rX2T1iWK4ZR90pBtcPzS+2OObzTYz8go0PfeSTT6eq69Na1KcNLaE= - - UNISH_NO_TIMEOUTS=y - - UNISH_DB_URL=mysql://root:@127.0.0.1 - -matrix: - include: - # D9.0.x - - php: 7.4 - env: 'UNISH_DRUPAL_MAJOR_VERSION=9 UNISH_DRUPAL_MINOR_VERSION=0.x-dev' - - # D8.9.x - - php: 7.4 - env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=9.x-dev' - - # D8.8.x - - php: 7.3 - env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=8.5' - - # D8.7.x - - php: 7.2 - env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=7.12' - - # D8.6.x - - php: 7.1 - env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=6.18' - - # D8.5.x - - php: 7.1 - env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=5.15' - - # D8.4.x - - php: 7.1 - env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=4.8 PHPUNIT_ARGS=--group=commands' - - # D8.3.x - - php: 7.1 - env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=3.9 PHPUNIT_ARGS=--group=commands' - - # D8.2.x - - php: 7.0 - env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=2.8 PHPUNIT_ARGS=--group=commands' - - # D7 - - php: 7.1 - env: 'UNISH_DRUPAL_MAJOR_VERSION=7' - - # D7 - - php: 5.6 - env: 'UNISH_DRUPAL_MAJOR_VERSION=7' - - # D6 - - php: 7.0 - env: 'UNISH_DRUPAL_MAJOR_VERSION=6' - - # D6 - - php: 5.6 - env: 'UNISH_DRUPAL_MAJOR_VERSION=6' - -before_install: - - echo 'mbstring.http_input = pass' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - echo 'mbstring.http_output = pass' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - travis_retry composer selfupdate - -install: travis_retry composer install --no-interaction - -before_script: - - phpenv config-rm xdebug.ini - - echo 'sendmail_path = /bin/true' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - # - echo "sendmail_path='true'" >> `php --ini | grep "Loaded Configuration" | awk '{print $4}'` - - export UNISH_DRUSH="${PWD}/drush" - -script: ${PWD}/unish.sh $PHPUNIT_ARGS - -# Background: https://github.com/drush-ops/drush/pull/1426 -after_success: ${PWD}/tests/testChildren.sh - -before_deploy: - - gem install mime-types -v 2.6.2 # https://github.com/travis-ci/travis-ci/issues/5145 - - curl -LSs https://box-project.github.io/box2/installer.php | php - - composer install --prefer-dist --no-dev --optimize-autoloader --no-interaction - - php box.phar build - - test $TRAVIS_TAG=true && mkdir s3-stable && cp drush.phar s3-stable/drush.phar - - test $TRAVIS_BRANCH=master && mkdir s3-unstable && cp drush.phar s3-unstable/drush-unstable.phar -deploy: - # http://docs.travis-ci.com/user/deployment/releases/ - - provider: releases - skip_cleanup: true - api_key: - secure: vRtKwJNzm+FXS5VCsaCu5YM4IS02tAdqV4G557HEyVzNgRmSgPWkaHDR/95TnXtZRjmxuTI++rccEj9+jzjknQ9LWkWhl13WiJdZYobnb240f9Ja8g0gs6/r+EEZG2+DTTerK9zicpf51h5hUaE46zObHjSmzIuGxZBO1syDld8= - file: drush.phar - on: - tags: true - repo: drush-ops/drush - all_branches: true From 0b12305c9865ae38a6476a8ba77035ac2823c0a3 Mon Sep 17 00:00:00 2001 From: Suzy Masri Date: Mon, 22 Jun 2020 09:59:38 +0300 Subject: [PATCH 19/20] Modified .travis.yml --- .travis.yml | 15 +++++++++------ database_sanitize.info.yml | 2 +- travis.php.ini | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 travis.php.ini diff --git a/.travis.yml b/.travis.yml index 29fd92b..595d5eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,13 @@ language: php php: - - 7.1 + - 7.3 matrix: fast_finish: true -dist: trusty +services: + - mysql # Skip tests for tags. if: tag IS blank @@ -30,12 +31,14 @@ before_install: install: - composer global require drupal/coder --prefer-dist -vvv || exit 1 - phpcs --config-set installed_paths "$COMPOSER_VENDOR_PATH/drupal/coder/coder_sniffer" + - phpenv config-add travis.php.ini + - php -ini | grep memory_limit before_script: - composer install -vvv - - cd "$TRAVIS_BUILD_DIR/vendor/"; git clone --branch 10.2.2 https://github.com/drush-ops/drush.git drush-tests - - cd "$TRAVIS_BUILD_DIR/vendor/drush-tests"; composer install - + - cd "$TRAVIS_BUILD_DIR/vendor/"; rm -rf drush; git clone --branch 10.2.2 https://github.com/drush-ops/drush.git drush + - cd "$TRAVIS_BUILD_DIR/vendor/drush"; composer install + script: - phpcs --standard=Drupal --ignore=vendor/* --warning-severity=0 . - - php "$TRAVIS_BUILD_DIR/vendor/drush-tests/vendor/bin/phpunit" --configuration "$TRAVIS_BUILD_DIR/vendor/drush-tests/tests" "$TRAVIS_BUILD_DIR/drush/tests" + - php "$TRAVIS_BUILD_DIR/vendor/drush/vendor/bin/phpunit" --configuration "$TRAVIS_BUILD_DIR/vendor/drush/tests" "$TRAVIS_BUILD_DIR/drush/tests" diff --git a/database_sanitize.info.yml b/database_sanitize.info.yml index 201b63d..295aa63 100644 --- a/database_sanitize.info.yml +++ b/database_sanitize.info.yml @@ -1,4 +1,4 @@ name: 'Database Sanitize' type: module description: 'Provides drush commands for yaml sanitization files checks and generation.' -core: 8.x +core_version_requirement: ^8 || ^9 diff --git a/travis.php.ini b/travis.php.ini new file mode 100644 index 0000000..7999e96 --- /dev/null +++ b/travis.php.ini @@ -0,0 +1 @@ +memory_limit = -1 From 57aaab8d5d94ee1e1771d0a628576487ec756ddf Mon Sep 17 00:00:00 2001 From: Suzy Masri Date: Mon, 24 Aug 2020 20:31:33 +0300 Subject: [PATCH 20/20] D9 deprecation fixes --- composer.json | 2 +- src/Commands/DatabaseSanitizeCommands.php | 11 +++++------ src/DatabaseSanitize.php | 15 +++++++++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 5ff06da..104ec89 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "extra": { "drush": { "services": { - "drush.services.yml": "^9 || ^10" + "drush.services.yml": "^9" } } } diff --git a/src/Commands/DatabaseSanitizeCommands.php b/src/Commands/DatabaseSanitizeCommands.php index 09af7bf..0c7f037 100644 --- a/src/Commands/DatabaseSanitizeCommands.php +++ b/src/Commands/DatabaseSanitizeCommands.php @@ -55,14 +55,14 @@ public function analyze(array $options = ['file' => NULL, 'list' => NULL]) { $missing_tables = $this->sanitizer->getUnspecifiedTables($file); if (!$missing_tables) { - $this->logger()->info(dt('All database tables are already specified in sanitize YML files')); + \Drupal::logger('database_sanitize')->log('success', (dt('All database tables are already specified in sanitize YML files'))); return; } - $this->logger()->warning(dt('There are @count tables not defined on sanitize YML files', ['@count' => count($missing_tables)])); + \Drupal::logger('database_sanitize')->log('warning', (dt('There are @count tables not defined on sanitize YML files', ['@count' => count($missing_tables)]))); if (!empty($options['list'])) { - $this->logger()->warning(implode("\n", $missing_tables)); + \Drupal::logger('database_sanitize')->log('warning', (implode("\n", $missing_tables))); } } @@ -81,8 +81,7 @@ public function analyze(array $options = ['file' => NULL, 'list' => NULL]) { * @command db:sanitize-generate * @aliases dbsg,db-sanitize-generate * - * @return array - * Array of sanitization entries - TODO: more info. + * @return Consolidation\OutputFormatters\Formatters\YamlFormatter * * @throws \Exception */ @@ -99,7 +98,7 @@ public function generate(array $options = ['file' => NULL, 'machine-name' => NUL $yml_file_path = $options['file']; $missing_tables = $this->sanitizer->getUnspecifiedTables($yml_file_path); if (!$missing_tables) { - $this->logger()->info(dt('All database tables are already specified in sanitize YML files')); + \Drupal::logger('database_sanitize')->log('success', (dt('All database tables are already specified in sanitize YML files'))); return []; } diff --git a/src/DatabaseSanitize.php b/src/DatabaseSanitize.php index d8449eb..f6871b0 100644 --- a/src/DatabaseSanitize.php +++ b/src/DatabaseSanitize.php @@ -177,6 +177,7 @@ public function getDatabaseSanitizeYmlFileContent() { */ public function getUnspecifiedTables($yml_file_path = NULL) { if ($yml_file_path) { + if (!file_exists($yml_file_path)) { throw new \Exception("File does not exist $yml_file_path"); } @@ -199,13 +200,13 @@ public function getUnspecifiedTables($yml_file_path = NULL) { } catch (ParseException $exception) { $message = $exception->getMessage(); - $this->logger->error("Unable to parse the sanitize YAML file. @message", ['@message' => $message]); + \Drupal::logger('database_sanitize')->log('error', (dt("Unable to parse the sanitize YAML file. @message", ['@message' => $message]))); return $db_tables; } if (is_null($parsed_file) || !array_key_exists('sanitize', $parsed_file)) { - $this->logger->error("The 'sanitize' key is not defined"); + \Drupal::logger('database_sanitize')->log('error', (dt("The 'sanitize' key is not defined"))); return $db_tables; } @@ -218,12 +219,12 @@ public function getUnspecifiedTables($yml_file_path = NULL) { foreach ($parsed_file['sanitize'] as $machine_name => $tables) { foreach ($tables as $table_name => $definition) { if (is_array($definition) && !array_key_exists('description', $definition)) { - $this->logger->warning('Table \'@table_name\' defined by \'@machine_name\' does not specify a \'description\' key', ['@table_name' => $table_name, '@machine_name' => $machine_name]); + \Drupal::logger('database_sanitize')->log('warning', (dt('Table \'@table_name\' defined by \'@machine_name\' does not specify a \'description\' key', ['@table_name' => $table_name, '@machine_name' => $machine_name]))); continue; } if (is_array($definition) && !array_key_exists('query', $definition)) { - $this->logger->warning('Table \'@table_name\' defined by \'@machine_name\' does not specify a \'query\' key', ['@table_name' => $table_name, '@machine_name' => $machine_name]); + \Drupal::logger('database_sanitize')->log('warning', (dt('Table \'@table_name\' defined by \'@machine_name\' does not specify a \'query\' key', ['@table_name' => $table_name, '@machine_name' => $machine_name]))); continue; } @@ -248,10 +249,12 @@ public function getUnspecifiedTables($yml_file_path = NULL) { $missing = array_diff($db_tables, $yml_tables); if (is_array($missing) && empty($missing)) { - $this->logger->info('All database tables are already specified in sanitize YML files'); + \Drupal::logger('database_sanitize')->log('success', (dt('All database tables are already specified in sanitize YML files'))); return []; - } + } else { + \Drupal::logger('database_sanitize')->log('warning', (dt('There are @count tables not defined on sanitize YML files', ['@count' => count($missing)]))); + } sort($missing);