doctrine-mysql-come-back icon indicating copy to clipboard operation
doctrine-mysql-come-back copied to clipboard

Deprecation warning

Open stevenbrookes opened this issue 3 years ago • 5 comments

Hi

Thanks for this library - it's been working very well for us. I'm seeing this deprecation warning in our Symfony project

The "Doctrine\DBAL\Connection::__construct()" method is considered internal The connection can be only instantiated by the driver manager. It may change without further notice. You should not extend it from "Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection".

This is with doctrine/dbal 2.12.0. I imagine this isn't a real problem yet, but annoying as this gets flagged up as part of our build process. Is there a way to achieve what this library does without overriding the constructor? Or perhaps a way to turn off the warning at least.

Regards

Steve

stevenbrookes avatar Oct 29 '20 12:10 stevenbrookes

We could try to use a decorator pattern instead of extension, but I'm not sure if everything that we need to accomplish is doable in that way...

Jean85 avatar Oct 30 '20 07:10 Jean85

Umh, this seems counter-intuitive, but avoiding extending Doctrine\DBAL\Connection is NOT doable, you get this error:

Doctrine\DBAL\Exception: The given 'wrapperClass' Facile\DoctrineMySQLComeBack\Doctrine\DBAL\FunctionalTest\Connection has to be a subtype of \Doctrine\DBAL\Connection.

vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:221
vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php:195
...

Jean85 avatar Oct 30 '20 09:10 Jean85

Yeah that does seem odd, if the only way to wrap is by extending then either the deprecation message is incorrect or doctrine needs to provide another way to wrap the connection. I suspect we might have to live with the warning for a while until this is resolved by doctrine and an way forward becomes apparent.

stevenbrookes avatar Oct 30 '20 10:10 stevenbrookes

The deprecation warning seems to come from Symfony's DebugClassLoader.

I think the only way is to disable E_USER_DEPRECATED errors in production, but it seems not possible to remove them completely.

thomasvargiu avatar Oct 31 '20 10:10 thomasvargiu

Another important deprecation to consider:

\Doctrine\DBAL\Driver\PDOMySql\Driver is deprecated in favor of \Doctrine\DBAL\Driver\PDO\MySQL\Driver, which is final.

https://github.com/doctrine/dbal/pull/4144

mathop avatar Nov 25 '20 17:11 mathop

Closing as everything is now correctly handled in 2.0. Unfortunately, I don't have the bandwidth to fix the deprecations in 1.x, and I'm not even sure those are fixable.

Jean85 avatar Apr 01 '23 21:04 Jean85