dmaicher/doctrine-test-bundle

Deprecation: Subscribing to `postConnect` events is deprecated. Implement a middleware instead.

ruudk opened this issue ยท 5 comments

ruudk commented

First of all, thanks for this amazing bundle ๐Ÿ’™

It seems that it's using a postConnect listener that is being deprecated.

We were using the postConnect listener too in our project and we solved it by using a middleware like this:

<?php

final readonly class DriverMiddleware implements Middleware
{
    public function wrap(DriverInterface $driver) : DriverInterface
    {
        return new MyDriver($driver);
    }
}

final class MyDriver extends AbstractDriverMiddleware
{
    public function connect(
        #[SensitiveParameter]
        array $params,
    ) : DriverConnection {
        $connection = parent::connect($params);
        // do post connect

        return $connection;
    }
}

Do you think this could be a solution? If so, I could try to create a PR. But you probably know better if it could work or not.

see the latest 8.0 Beta release ๐Ÿ˜‰ please test it

ruudk commented

Wow., didn't know.

I just ran it on our large functional test suite (ยฑ2000 tests split over 3 jobs) and it works great.

The deprecation is gone, but a new one appeared:

Nesting transactions without enabling savepoints is deprecated.
Call Doctrine\DBAL\Connection::setNestTransactionsWithSavepoints(true) to enable savepoints. (Connection.php:1373 called by UnitOfWork.php:415, https://github.com/doctrine/dbal/pull/5383, package doctrine/dbal)

For this deprecation you should configure use_savepoints: true on the dbal connection. See https://github.com/dmaicher/doctrine-test-bundle/blob/master/tests/Functional/app/config.yml#L12 for example.

ruudk commented

That did the trick. Thanks for pointing me towards that.

So to summarize, 8.0 Beta 1 rocks! So glad that the previous deprecation (VersionAware) is gone now. Really happy with that.

+1 for 8.0 GM ๐Ÿ˜‰

Nice! Thanks for the feedback. I will think about actually making use_savepoints: true a requirement for 8.0. It does not make sense to use the bundle without enabling it.

Apart from that waiting a bit longer to see if there are more breaking changes with DBAL 4 that I could address in 8.0