Skip to content

Commit 6b61e26

Browse files
authored
Fix calls to AbstractSchemaManager::createSchema() (#10165)
1 parent edad800 commit 6b61e26

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lib/Doctrine/ORM/Tools/SchemaTool.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ public function getDropSchemaSQL(array $classes)
878878
{
879879
$schema = $this->getSchemaFromMetadata($classes);
880880

881-
$deployedSchema = $this->schemaManager->createSchema();
881+
$deployedSchema = $this->introspectSchema();
882882

883883
foreach ($schema->getTables() as $table) {
884884
if (! $deployedSchema->hasTable($table->getName())) {
@@ -974,7 +974,7 @@ private function createSchemaForComparison(Schema $toSchema): Schema
974974
$previousFilter = $config->getSchemaAssetsFilter();
975975

976976
if ($previousFilter === null) {
977-
return $this->schemaManager->createSchema();
977+
return $this->introspectSchema();
978978
}
979979

980980
// whitelist assets we already know about in $toSchema, use the existing filter otherwise
@@ -985,10 +985,19 @@ private function createSchemaForComparison(Schema $toSchema): Schema
985985
});
986986

987987
try {
988-
return $this->schemaManager->createSchema();
988+
return $this->introspectSchema();
989989
} finally {
990990
// restore schema assets filter
991991
$config->setSchemaAssetsFilter($previousFilter);
992992
}
993993
}
994+
995+
private function introspectSchema(): Schema
996+
{
997+
$method = method_exists($this->schemaManager, 'introspectSchema')
998+
? 'introspectSchema'
999+
: 'createSchema';
1000+
1001+
return $this->schemaManager->$method();
1002+
}
9941003
}

psalm.xml

-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@
6969
<referencedMethod name="Doctrine\DBAL\Connection::getSchemaManager"/>
7070
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::getGuidExpression"/>
7171
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::supportsForeignKeyConstraints"/>
72-
<!-- Remove on 2.14.x -->
73-
<referencedMethod name="Doctrine\DBAL\Schema\AbstractSchemaManager::createSchema"/>
74-
<referencedMethod name="Doctrine\DBAL\Schema\Index::isFullfilledBy"/>
75-
<referencedMethod name="Doctrine\DBAL\Schema\Table::changeColumn"/>
76-
<referencedMethod name="Doctrine\DBAL\Schema\Table::hasPrimaryKey"/>
7772
<!-- Remove on 3.0.x -->
7873
<referencedMethod name="Doctrine\DBAL\Connection::getEventManager"/>
7974
<referencedMethod name="Doctrine\DBAL\Schema\Schema::visit"/>

0 commit comments

Comments
 (0)