8000 [Messenger] Fix calls to deprecated DBAL methods by derrabus · Pull Request #46941 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Fix calls to deprecated DBAL methods #46941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2022
Merged
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
< 8000 div style="left: -107px; top: -7px" data-view-component="true" class="Popover-message Box position-relative mx-auto text-left color-shadow-large p-2 mt-2">
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/Symfony/Component/Messenger/Transport/Doctrine/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaDiff;
use Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
Expand Down Expand Up @@ -453,8 +454,9 @@ private function updateSchema(): void
return;
}

$comparator = new Comparator();
$schemaDiff = $comparator->compare($this->createSchemaManager()->createSchema(), $this->getSchema());
$schemaManager = $this->createSchemaManager();
$comparator = $this->createComparator($schemaManager);
$schemaDiff = $this->compareSchemas($comparator, $schemaManager->createSchema(), $this->getSchema());

foreach ($schemaDiff->toSaveSql($this->driverConnection->getDatabasePlatform()) as $sql) {
if (method_exists($this->driverConnection, 'executeStatement')) {
Expand All @@ -471,4 +473,18 @@ private function createSchemaManager(): AbstractSchemaManager
? $this->driverConnection->createSchemaManager()
: $this->driverConnection->getSchemaManager();
}

private function createComparator(AbstractSchemaManager $schemaManager): Comparator
{
return method_exists($schemaManager, 'createComparator')
? $schemaManager->createComparator()
: new Comparator();
}

private function compareSchemas(Comparator $comparator, Schema $from, Schema $to): SchemaDiff
{
return method_exists($comparator, 'compareSchemas')
? $comparator->compareSchemas($from, $to)
: $comparator->compare($from, $to);
}
}
0