Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .composer-require-checker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"symbol-whitelist": [
"Doctrine\\Common\\EventSubscriber",
"Doctrine\\DBAL\\Event\\SchemaColumnDefinitionEventArgs",
"Doctrine\\DBAL\\Events"
]
}
4 changes: 3 additions & 1 deletion .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ jobs:
composer update --no-interaction --no-scripts --no-progress
composer show
- name: ComposerRequireChecker
uses: docker://ghcr.io/webfactory/composer-require-checker:4.8.0
uses: docker://ghcr.io/webfactory/composer-require-checker:4.18.0
with:
args: --config-file=.composer-require-checker.json
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ext-SimpleXML": "*",
"ext-libxml": "*",
"ext-pdo": "*",
"doctrine/dbal": "^2.13 || ^3.0",
"doctrine/dbal": "^3.3 || ^4.0",
"doctrine/event-manager": "^1.0 || ^2.0",
"fakerphp/faker": "^1.14",
"symfony/console": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
Expand Down
42 changes: 17 additions & 25 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Webfactory/Slimdump/Database/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private function dumpData(Schema\Table $asset, Table $tableConfig): void
$progress->setRedrawFrequency((int) max($numRows / 100, 1));
$progress->start();

$wrappedConnection = $this->connection->getWrappedConnection();
$wrappedConnection = $this->connection->getNativeConnection();
if ($wrappedConnection instanceof PDO) {
$pdo = $wrappedConnection;
} elseif ($wrappedConnection instanceof \Doctrine\DBAL\Driver\PDO\Connection) {
Expand Down
2 changes: 1 addition & 1 deletion src/Webfactory/Slimdump/DumpTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function dump()

$db = $this->connection;

$manager = $db->getSchemaManager();
$manager = $db->createSchemaManager();

foreach (array_merge($manager->listTables(), $manager->listViews()) as $asset) {
$tableConfig = $this->config->findTable($asset->getName());
Expand Down
20 changes: 18 additions & 2 deletions src/Webfactory/Slimdump/SlimdumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\PDO\MySQL\Driver as PDOMySqlDriver;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Tools\DsnParser;
use RuntimeException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -69,7 +70,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$progressOutput = $this->createProgressOutput($input, $output);

$connection = $this->createConnection($input);
$connection->getEventManager()->addEventSubscriber(new DummyTypeRegistrationEventSubscriber($connection->getSchemaManager()));

// In DBAL 3, the SchemaManager parses DC2Type column comments and throws when encountering
// unknown types. We register a DummyType for any unknown type to work around this.
// In DBAL 4, the DC2Type comment mechanism was removed entirely, so this is no longer needed.
if (class_exists(\Doctrine\DBAL\Events::class)) {
$connection->getEventManager()->addEventSubscriber(new DummyTypeRegistrationEventSubscriber($connection->createSchemaManager()));
}

$this->setMaxExecutionTimeUnlimited($connection, $progressOutput);

$config = ConfigBuilder::createConfigurationFromConsecutiveFiles($input->getArgument('config'));
Expand Down Expand Up @@ -146,8 +154,16 @@ private function createConnection(InputInterface $input): Connection
}

$mysqliIndependentDsn = preg_replace('_^mysqli:_', 'mysql:', $dsn);

if (class_exists(DsnParser::class)) {
// DBAL 4: the 'url' connection parameter was removed in favour of DsnParser
$params = (new DsnParser(['mysql' => 'pdo_mysql']))->parse($mysqliIndependentDsn);
} else {
$params = ['url' => $mysqliIndependentDsn];
}

$connection = DriverManager::getConnection(
['url' => $mysqliIndependentDsn, 'charset' => 'utf8', 'driverClass' => PDOMySqlDriver::class]
array_merge($params, ['charset' => 'utf8', 'driverClass' => PDOMySqlDriver::class])
);

return $connection;
Expand Down