dbal icon indicating copy to clipboard operation
dbal copied to clipboard

[API] Add getWrappedDriver method to AbstractDriverMiddleware

Open oleg-andreyev opened this issue 1 year ago • 2 comments

Feature Request

There are cases when it's required to extact$wrappedDriver but AbstractDriverMiddleware does not have such public api.

https://github.com/DamienHarper/auditor/issues/184

Q A
New Feature yes
RFC yes

Summary

Adding get-method for $wrappedDriver

oleg-andreyev avatar Feb 19 '24 12:02 oleg-andreyev

There are cases when it's required to extact$wrappedDriver

And which cases would that be? The middleware stacks are not designed to be unwrapped and that's kind of on purpose.

but AbstractDriverMiddleware does not have such public api.

Please be aware that AbstractDriverMiddleware is by no means a contract. It's a utility class. The contract of a driver middleware class is the Driver interface. A class that only implements that interface and not the abstract class is still a valid driver middleware class.

So, even if we did add such a method to AbstractDriverMiddleware, it would not guarantee that you could actually unwrap the whole driver stack.

I don't know what problem you are trying to solve, but I would kindly ask you to find a different way.

derrabus avatar Feb 19 '24 17:02 derrabus

Case is mentioned here https://github.com/DamienHarper/auditor/issues/184 and https://github.com/DamienHarper/auditor/blob/8edca5bedfda2f838003471321c60c45d941ba03/src/Provider/Doctrine/Auditing/Event/DoctrineSubscriber.php#L37-L42

this could be a wrong implementation from auditor lib, but it's OCP, we decorate connection/driver to add extra functionality - so imo valid solution to check instance if needed, but because driver/connection could be wrapped by many other decorators logic could be broken, that's why need to rewind or unwrap.

oleg-andreyev avatar Feb 19 '24 22:02 oleg-andreyev