theofidry / AliceDataFixtures

Nelmio Alice extension to persist the loaded fixtures.
MIT License
311 stars 71 forks source link

Throws a deprecation notice with Doctrine ORM ^2.14 #234

Closed fatalist closed 1 year ago

fatalist commented 1 year ago
Doctrine\DBAL\Connection::exec is deprecated, please use executeStatement() instead. (Connection.php:1995 called by Purger.php:107, https://github.com/doctrine/dbal/pull/4163, package doctrine/dbal)

The following code:

// src/Bridge/Doctrine/Purger/Purger.php
if ($disableFkChecks) {
    $connection = $this->purger->getObjectManager()->getConnection();
    $connection->exec('SET FOREIGN_KEY_CHECKS = 0;');
}
$this->purger->purge();
if ($disableFkChecks && isset($connection)) {
    $connection->exec('SET FOREIGN_KEY_CHECKS = 1;');
}

Should be replaced with:

// src/Bridge/Doctrine/Purger/Purger.php
if ($disableFkChecks) {
    $connection = $this->purger->getObjectManager()->getConnection();
    $connection->executeStatement('SET FOREIGN_KEY_CHECKS = 0;');
}
$this->purger->purge();
if ($disableFkChecks && isset($connection)) {
    $connection->executeStatement('SET FOREIGN_KEY_CHECKS = 1;');
}
alexislefebvre commented 1 year ago

The title says that it “Doesn't work” but the description shows a deprecation. Does it work even though there is a deprecation message?

fatalist commented 1 year ago

The title says that it “Doesn't work” but the description shows a deprecation. Does it work even though there is a deprecation message?

It's my fault. The title is now correct. It works, but with notices.