Skip to content

Commit

Permalink
[TASK] Ensure to set a SchemaManagerFactory for lowlevel connection
Browse files Browse the repository at this point in the history
The doctrine team deprecated the instantiation of a connection
using `DriverManager::getConnection()` without a configuration
object [1].

This change ensures to set the default doctrine factory, but
sets the TYPO3 core implementation with TYPO3 v13.0 to provide
the custom SchemaManager for the different platforms.

[1] https://github.com/doctrine/dbal/blob/3.7.x/UPGRADE.md#deprecated-not-setting-a-schema-manager-factory

Releases: main
  • Loading branch information
sbuerk committed Nov 23, 2023
1 parent 3e9a846 commit 8693e48
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Classes/Core/Testbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,16 @@ public function setUpTestDatabase(string $databaseName, string $originalDatabase
// @todo: This should by now work with using "our" ConnectionPool again, it does now, though.
$connectionParameters = $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default'];
unset($connectionParameters['dbname']);
$connection = DriverManager::getConnection($connectionParameters);
$configuration = (new Configuration())->setSchemaManagerFactory(GeneralUtility::makeInstance(DefaultSchemaManagerFactory::class));
// @todo Remove class exist check if supported minimal TYPO3 version is raised to v13+.
if (class_exists(\TYPO3\CMS\Core\Database\Schema\SchemaManager\CoreSchemaManagerFactory::class)) {
/** @var SchemaManagerFactory|\TYPO3\CMS\Core\Database\Schema\SchemaManager\CoreSchemaManagerFactory $coreSchemaFactory */
$coreSchemaFactory = GeneralUtility::makeInstance(
\TYPO3\CMS\Core\Database\Schema\SchemaManager\CoreSchemaManagerFactory::class
);
$configuration->setSchemaManagerFactory($coreSchemaFactory);
}
$connection = DriverManager::getConnection($connectionParameters, $connection);
$schemaManager = $connection->createSchemaManager();
$platform = $connection->getDatabasePlatform();
$isSQLite = $platform instanceof DoctrineSQLitePlatform;
Expand Down

0 comments on commit 8693e48

Please sign in to comment.