LiipTestFixturesBundle icon indicating copy to clipboard operation
LiipTestFixturesBundle copied to clipboard

[Bug]: Not configuring a schema manager factory is deprecated. Use %s which is going to be the default in DBAL 4.

Open KoNekoD opened this issue 1 year ago • 1 comments

Preconditions

  protected function createDatabaseIfNotExists(): void
    {
        $params = $this->connection->getParams();

        // doctrine-bundle >= 2.2
        if (isset($params['primary'])) {
            $params = $params['primary'];
        }
        // doctrine-bundle < 2.2
        elseif (isset($params['master'])) {
            $params = $params['master'];
        }
        $dbName = $params['dbname'] ?? '';

        unset($params['dbname'], $params['url']);

        // Unset url to avoid issue:
        // “An exception occurred in driver: SQLSTATE[HY000] [1049] Unknown database 'test'”

        $tmpConnection = DriverManager::getConnection($params, <- here needed to inject configuration with defined schema manager);

Steps to reproduce

Just start use library

Expected result

No deprecations

Actual result

Has deprecations

KoNekoD avatar Jul 04 '24 15:07 KoNekoD

Thanks for the report, what is %s in this context? Do you have more information about this deprecation?

alexislefebvre avatar Jul 15 '24 09:07 alexislefebvre

I have the same issue and in my case %s is Doctrine\DBAL\Schema\DefaultSchemaManagerFactory.

Full notice:

Not configuring a schema manager factory is deprecated. Use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory which is going to be the default in DBAL 4. (Connection.php:222 called by DriverManager.php:197, https://github.com/doctrine/dbal/issues/5812, package doctrine/dbal)

arzamaskov avatar Dec 10 '24 18:12 arzamaskov

Thanks for the deprecation message.

It comes from these lines: https://github.com/doctrine/dbal/blob/0ac3d64b6159eb2abccb7945c7969c76da30f5bb/src/Connection.php#L225-L236

The call is initiated by: https://github.com/liip/LiipTestFixturesBundle/blob/91ef15e1e4bf96c2a3b9d4374c6410bd08d5b471/src/Services/DatabaseTools/ORMDatabaseTool.php#L174

The deprecation message contains this link:

  • https://github.com/doctrine/dbal/issues/5812

That was closed by:

  • https://github.com/doctrine/dbal/pull/5876

I don't understand what are the required changes.

But I have no issue when loading fixtures in a project that use doctrine/dbal 4.2.1, so it looks like it works with DBAL 4.x.

alexislefebvre avatar Dec 16 '24 15:12 alexislefebvre

Please try the last release: https://github.com/liip/LiipTestFixturesBundle/releases/tag/3.2.1

alexislefebvre avatar Dec 16 '24 16:12 alexislefebvre