diff --git a/.composer-require-checker.json b/.composer-require-checker.json index 3cce1e9..316d7f0 100644 --- a/.composer-require-checker.json +++ b/.composer-require-checker.json @@ -2,6 +2,7 @@ "symbol-whitelist": [ "Doctrine\\Common\\EventSubscriber", "Doctrine\\DBAL\\Event\\SchemaColumnDefinitionEventArgs", - "Doctrine\\DBAL\\Events" + "Doctrine\\DBAL\\Events", + "PDO\\Mysql" ] } diff --git a/.github/workflows/fix-cs-php.yml b/.github/workflows/fix-cs-php.yml index 81e45f4..7b7449c 100644 --- a/.github/workflows/fix-cs-php.yml +++ b/.github/workflows/fix-cs-php.yml @@ -17,8 +17,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v6 - with: - ref: ${{ github.head_ref }} - name: Run PHP-CS-Fixer uses: docker://ghcr.io/php-cs-fixer/php-cs-fixer:3.62.0-php8.3 diff --git a/src/Webfactory/Slimdump/Database/Dumper.php b/src/Webfactory/Slimdump/Database/Dumper.php index e3365cf..35dce8c 100644 --- a/src/Webfactory/Slimdump/Database/Dumper.php +++ b/src/Webfactory/Slimdump/Database/Dumper.php @@ -134,7 +134,7 @@ private function dumpData(Schema\Table $asset, Table $tableConfig): void } else { throw new RuntimeException('failed to obtain the wrapped PDO object from the DBAL connection'); } - $pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + $this->controlBufferedQuery($pdo, false); $actualRows = 0; $this->outputFormatDriver->beginTableDataDump($asset, $tableConfig); @@ -155,7 +155,7 @@ private function dumpData(Schema\Table $asset, Table $tableConfig): void $this->progressOutput->writeln(\sprintf('Expected %d rows, actually processed %d – verify results!', $numRows, $actualRows)); } - $pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $this->controlBufferedQuery($pdo, true); $this->outputFormatDriver->endTableDataDump($asset, $tableConfig); } @@ -166,4 +166,15 @@ public static function isBlob(Schema\Column $column): bool return $type instanceof BlobType || $type instanceof BinaryType; } + + private function controlBufferedQuery(PDO $pdo, bool $value): void + { + if (version_compare(\PHP_VERSION, '8.4.0', '<')) { + $pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + + return; + } + + $pdo->setAttribute(PDO\Mysql::ATTR_USE_BUFFERED_QUERY, $value); + } }