diff --git a/composer.json b/composer.json index 4307ec9..20aad95 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "A drop-in replacement for mysqldump that optionally sanitizes DB fields for better GDPR conformity.", "require": { "symfony/console": "^3.0", - "ifsnop/mysqldump-php": "dev-master", + "ifsnop/mysqldump-php": "^2.9", "cweagans/composer-patches": "^1.6", "bomoko/mysql-cnf-parser": "^0.0.2", "fzaninotto/faker": "^1.7", diff --git a/src/MysqldumpGdpr.php b/src/MysqldumpGdpr.php index 1b384aa..e11f2b9 100644 --- a/src/MysqldumpGdpr.php +++ b/src/MysqldumpGdpr.php @@ -39,6 +39,7 @@ public function __construct( $this->debugSql = $dumpSettings['debug-sql']; unset($dumpSettings['debug-sql']); } + $this->setTransformTableRowHook([$this, 'hookTransformRow']); parent::__construct($dsn, $user, $pass, $dumpSettings, $pdoSettings); } @@ -61,15 +62,17 @@ public function getColumnStmt($tableName) return $columnStmt; } - protected function hookTransformColumnValue($tableName, $colName, $colValue) + protected function hookTransformRow($tableName, array $row) { - if (!empty($this->gdprReplacements[$tableName][$colName])) { - $replacement = ColumnTransformer::replaceValue($tableName, $colName, $this->gdprReplacements[$tableName][$colName]); - if($replacement !== FALSE) { - return $replacement; + foreach ($row as $colName => &$colValue) { + if (!empty($this->gdprReplacements[$tableName][$colName])) { + $replacement = ColumnTransformer::replaceValue($tableName, $colName, $this->gdprReplacements[$tableName][$colName]); + if($replacement !== FALSE) { + $colValue = $replacement; + } } } - return $colValue; + return $row; } }