Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the portability layer to act as a middleware #4157

Merged
merged 2 commits into from
Jul 9, 2020

Conversation

morozov
Copy link
Member

@morozov morozov commented Jul 9, 2020

Q A
Type bug, improvement
BC Break yes

Fixes #4156.

Importance

Apart from the fatal error reported in the linked issue, the current implementation blocks the decoupling of the driver and wrapper APIs. The wrapper-level Connection::prepare() declares its return type as DriverStatement (which is not intended but required by the driver-level Connection interface) however it returns a Statement (a more specific and feature-rich type):

dbal/src/Connection.php

Lines 908 to 912 in 98c23fe

* @return Statement
*
* @throws DBALException
*/
public function prepare(string $sql): DriverStatement

Even if it stops implementing the driver connection interface, it cannot declare its return type as Statement because the Portability\Connection class currently extends it and returns a driver-level statement:

/**
* Portability wrapper for a Statement.
*/
class Statement implements DriverStatement

The Driver Middleware concept

The concept of a driver middleware will allow extending the behavior of the DBAL connection by wrapping the underlying driver. Once the driver is wrapped, the wrapper can also wrap the connection and the statement objects effectively extending any of the behaviors. The middleware objects are registered via configuration (see example in the test).

Apart from the portability layer, it can be used to reimplement the caching layer which is currently implemented as part of the wrapper connection class.

Portability layer reworked

The portability layer has been reworked to act as middleware and implement only the driver-level APIs.

UPGRADE.md Outdated Show resolved Hide resolved
src/Portability/Driver.php Outdated Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The portability spans two different architecture layers and doesn't properly implement the wrapper API
2 participants