Skip to content

Commit 43126b1

Browse files
committed
bug symfony#46941 [Messenger] Fix calls to deprecated DBAL methods (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- [Messenger] Fix calls to deprecated DBAL methods | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A Follows doctrine/dbal#4746 and doctrine/dbal#4707. Commits ------- 2f834f2 [Messenger] Fix calls to deprecated DBAL methods
2 parents 8a62b40 + 2f834f2 commit 43126b1

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Doctrine\DBAL\Schema\AbstractSchemaManager;
2626
use Doctrine\DBAL\Schema\Comparator;
2727
use Doctrine\DBAL\Schema\Schema;
28+
use Doctrine\DBAL\Schema\SchemaDiff;
2829
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
2930
use Doctrine\DBAL\Types\Type;
3031
use Doctrine\DBAL\Types\Types;
@@ -453,8 +454,9 @@ private function updateSchema(): void
453454
return;
454455
}
455456

456-
$comparator = new Comparator();
457-
$schemaDiff = $comparator->compare($this->createSchemaManager()->createSchema(), $this->getSchema());
457+
$schemaManager = $this->createSchemaManager();
458+
$comparator = $this->createComparator($schemaManager);
459+
$schemaDiff = $this->compareSchemas($comparator, $schemaManager->createSchema(), $this->getSchema());
458460

459461
foreach ($schemaDiff->toSaveSql($this->driverConnection->getDatabasePlatform()) as $sql) {
460462
if (method_exists($this->driverConnection, 'executeStatement')) {
@@ -471,4 +473,18 @@ private function createSchemaManager(): AbstractSchemaManager
471473
? $this->driverConnection->createSchemaManager()
472474
: $this->driverConnection->getSchemaManager();
473475
}
476+
477+
private function createComparator(AbstractSchemaManager $schemaManager): Comparator
478+
{
479+
return method_exists($schemaManager, 'createComparator')
480+
? $schemaManager->createComparator()
481+
: new Comparator();
482+
}
483+
484+
private function compareSchemas(Comparator $comparator, Schema $from, Schema $to): SchemaDiff
485+
{
486+
return method_exists($comparator, 'compareSchemas')
487+
? $comparator->compareSchemas($from, $to)
488+
: $comparator->compare($from, $to);
489+
}
474490
}

0 commit comments

Comments
 (0)