diff --git a/README.md b/README.md
index 381b8d9..c120e80 100644
--- a/README.md
+++ b/README.md
@@ -9,13 +9,13 @@ and can in principle dump any database that PDO supports.
Require druidfi/gdpr-mysqldump with Composer:
-```
+```console
composer require druidfi/drush-gdpr-dumper
```
Enable the module in Drupal UI or with Drush:
-```
+```console
drush en gdpr_dumper
```
@@ -24,13 +24,13 @@ drush en gdpr_dumper
If you want to create a sql dump on live servers for local purposes (as a developer, themer, ...),
you should use following command:
-```
+```console
drush sql-dump-gdpr > dump.sql
```
instead of
-```
+```console
drush sql-dump > dump.sql
```
@@ -41,7 +41,7 @@ be GDPR compliant YO!
In settings.php you can do the override configuration like this:
-```
+```php
$config['gdpr_dumper.settings']['gdpr_replacements'] = [
'users_field_data' => [ // Table
'name' => [ // Field
diff --git a/composer.json b/composer.json
index 85577e1..9fd31ff 100644
--- a/composer.json
+++ b/composer.json
@@ -21,14 +21,17 @@
}
],
"require": {
- "php": "^7.4 || ^8.0",
- "druidfi/gdpr-mysqldump": "^1.2.2",
- "drush/drush": "^11.4",
- "drupal/core-recommended": "^9 || ^10"
+ "php": "^8.1",
+ "druidfi/gdpr-mysqldump": "^1.2.6",
+ "drush/drush": "^13",
+ "drupal/core-recommended": "^10.3 || ^11"
},
"config": {
"allow-plugins": {
"cweagans/composer-patches": true
}
+ },
+ "require-dev": {
+ "webflo/drupal-finder": "^1.3"
}
}
diff --git a/config/install/gdpr_dumper.settings.yml b/config/install/gdpr_dumper.settings.yml
index 7a3faac..57a52f3 100644
--- a/config/install/gdpr_dumper.settings.yml
+++ b/config/install/gdpr_dumper.settings.yml
@@ -12,11 +12,5 @@ gdpr_replacements:
drivers:
mysql:
dump_command: 'mysqldump'
- oracle:
- dump_command: 'mysqldump'
pqsql:
dump_command: 'pg_dump'
- sqlite:
- dump_command: 'dump'
- sqlsrv:
- dump_command: 'mysqldump'
diff --git a/gdpr_dumper.info.yml b/gdpr_dumper.info.yml
index 01d3167..38792dc 100644
--- a/gdpr_dumper.info.yml
+++ b/gdpr_dumper.info.yml
@@ -1,4 +1,4 @@
name: GDPR dumper
description: 'A drop-in replacement for mysqldump that optionally sanitizes DB fields for better GDPR conformity.'
type: module
-core_version_requirement: ^9 || ^10
+core_version_requirement: ^10 || ^11
diff --git a/src/Commands/SqlCommands.php b/src/Commands/SqlCommands.php
index eceb4a6..8b2a97a 100644
--- a/src/Commands/SqlCommands.php
+++ b/src/Commands/SqlCommands.php
@@ -2,43 +2,47 @@
namespace Drupal\gdpr_dumper\Commands;
+use Consolidation\AnnotatedCommand\Input\StdinAwareInterface;
+use Consolidation\AnnotatedCommand\Input\StdinAwareTrait;
use Consolidation\OutputFormatters\StructuredData\PropertyList;
use Drupal\gdpr_dumper\Sql\GdprSqlBase;
-use Drush\Commands\sql\SqlCommands as SqlCommandsBase;
+use Drush\Attributes as CLI;
+use Drush\Boot\DrupalBootLevels;
+use Drush\Commands\DrushCommands;
+use Drush\Exec\ExecTrait;
/**
* Class SQlCommands
* @package Drupal\gdpr_dumper\Commands
*/
-class SqlCommands extends SqlCommandsBase
+final class SqlCommands extends DrushCommands implements StdinAwareInterface
{
+ use ExecTrait;
+ use StdinAwareTrait;
+
/**
- * Exports a GDPR compliant Drupal DB as SQL using mysqldump or equivalent.
+ * Exports a GDPR-compliant Drupal DB as SQL using mysqldump or equivalent.
*
- * @command sql:dump-gdpr
- * @aliases sql-dump-gdpr
- * @optionset_sql
- * @optionset_table_selection
- * @option result-file Save to a file. The file should be relative to Drupal root. If --result-file is provided with the value 'auto', a date-based filename will be created under ~/drush-backups directory.
- * @option create-db Omit DROP TABLE statements. Used by Postgres and Oracle only.
- * @option data-only Dump data without statements to create any of the schema.
- * @option ordered-dump Order by primary key and add line breaks for efficient diffs. Slows down the dump. Mysql only.
- * @option gzip Compress the dump using the gzip program which must be in your $PATH.
- * @option extra Add custom arguments/options when connecting to database (used internally to list tables).
- * @option extra-dump Add custom arguments/options to the dumping of the database (e.g. mysqldump command).
- * @usage drush sql:dump-gdpr --result-file=../18.sql
- * Save SQL dump to the directory above Drupal root.
- * @usage drush sql:dump-gdpr --skip-tables-key=common
- * Skip standard tables. @throws \Exception
- * @see example.drush.yml
- * @usage drush sql:dump-gdpr --extra-dump=--no-data
- * Pass extra option to mysqldump command.
* @hidden-options create-db
- * @bootstrap max configuration
*
* @notes
* createdb is used by sql-sync, since including the DROP TABLE statements interfere with the import when the database is created.
*/
+ #[CLI\Command(name: 'sql:dump-gdpr', aliases: ['sql-dump-gdpr'])]
+ #[CLI\Bootstrap(level: DrupalBootLevels::MAX, max_level: DrupalBootLevels::CONFIGURATION)]
+ #[CLI\OptionsetSql]
+ #[CLI\OptionsetTableSelection]
+ #[CLI\Option(name: 'result-file', description: "Save to a file. The file should be relative to Drupal root. If --result-file is provided with the value 'auto', a date-based filename will be created under ~/drush-backups directory.")]
+ #[CLI\Option(name: 'create-db', description: 'Omit DROP TABLE statements. Used by Postgres and Oracle only.')]
+ #[CLI\Option(name: 'data-only', description: 'Dump data without statements to create any of the schema.')]
+ #[CLI\Option(name: 'ordered-dump', description: 'Order by primary key and add line breaks for efficient diffs. Slows down the dump. Mysql only.')]
+ #[CLI\Option(name: 'gzip', description: 'Compress the dump using the gzip program which must be in your $PATH.')]
+ #[CLI\Option(name: 'extra', description: 'Add custom arguments/options when connecting to database (used internally to list tables).')]
+ #[CLI\Option(name: 'extra-dump', description: 'Add custom arguments/options to the dumping of the database (e.g. mysqldump command).')]
+ #[CLI\Usage(name: 'drush sql:dump-gdpr --result-file=../18.sql', description: 'Save SQL dump to the directory above Drupal root.')]
+ #[CLI\Usage(name: 'drush sql:dump-gdpr --skip-tables-key=common', description: 'Skip standard tables. See [Drush configuration](../../using-drush-configuration)')]
+ #[CLI\Usage(name: 'drush sql:dump-gdpr --extra-dump=--no-data', description: 'Pass extra option to mysqldump command.')]
+ #[CLI\FieldLabels(labels: ['path' => 'Path'])]
public function dump($options = ['result-file' => self::REQ, 'create-db' => false, 'data-only' => false, 'ordered-dump' => false, 'gzip' => false, 'extra' => self::REQ, 'extra-dump' => self::REQ, 'format' => 'null']): PropertyList
{
// Create new GDPR-compliant dump of DB.
@@ -55,5 +59,5 @@ public function dump($options = ['result-file' => self::REQ, 'create-db' => fals
}
return new PropertyList(['path' => $return]);
- }
+ }
}
diff --git a/src/Commands/SqlSyncCommands.php b/src/Commands/SqlSyncCommands.php
deleted file mode 100644
index eac7c42..0000000
--- a/src/Commands/SqlSyncCommands.php
+++ /dev/null
@@ -1,58 +0,0 @@
- true,
- 'result-file' => $options['source-dump'] ?: 'auto',
- ];
- if (!$options['no-dump']) {
- $this->logger()->notice(dt('Starting to dump database on source.'));
- $process = $this->processManager()->drush($sourceRecord, 'sql-dump-gdpr', [], $dump_options + ['format' => 'json']);
- $process->mustRun();
-
- if ($this->getConfig()->simulate()) {
- $source_dump_path = '/simulated/path/to/dump.tgz';
- } else {
- // First try a Drush 9.6+ return format.
- $json = $process->getOutputAsJson();
- if (!empty($json['path'])) {
- $source_dump_path = $json['path'];
- } else {
- // Next, try 9.5- format.
- $return = drush_backend_parse_output($process->getOutput());
- if (!$return['error_status'] || !empty($return['object'])) {
- $source_dump_path = $return['object'];
- }
- }
- }
- } else {
- $source_dump_path = $options['source-dump'];
- }
-
- if (empty($source_dump_path)) {
- throw new \Exception(dt('The Drush sql:dump command did not report the path to the dump file.'));
- }
- return $source_dump_path;
- }
-}
diff --git a/src/Sql/GdprSqlOracle.php b/src/Sql/GdprSqlOracle.php
deleted file mode 100644
index f5f509e..0000000
--- a/src/Sql/GdprSqlOracle.php
+++ /dev/null
@@ -1,15 +0,0 @@
-locateRoot(DRUPAL_ROOT);
+ $drupal_finder = new DrupalFinderComposerRuntime();
+ $drupal_finder->getDrupalRoot();
$vendor_dir = $drupal_finder->getVendorDir();
if ($vendor_dir && isset($this->driverOptions['dump_command'])) {
- // Replace default dump command with the GDPR compliant one.
+ // Replace default dump command with the GDPR-compliant one.
$cmd = str_replace($this->driverOptions['dump_command'], $vendor_dir . '/bin/mysqldump', $cmd);
}
@@ -33,7 +33,7 @@ public function getDriverOptions(): array
return $this->driverOptions;
}
- public function setDriverOptions(array $options)
+ public function setDriverOptions(array $options): void
{
$this->driverOptions = $options;
}