-
Notifications
You must be signed in to change notification settings - Fork 203
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
EZP-26885: As a Developer I want to future proof my Field Types by using Doctrine [in external storage] #1908
EZP-26885: As a Developer I want to future proof my Field Types by using Doctrine [in external storage] #1908
Conversation
One possible alternative solution to this is to inject into |
For the tmp commit can you replace the existing storage gateway while at it so we see the diff? (I assume we don't need the old one anymore in this case as it is part of kernel still) Or maybe you assume we will support both engines over time as they diverge? Mention that as I didn't quote get why we would move the storage registery out of the storage engine, unless what I wrote in beginning of this paragraph. |
Yes, I actually see Doctrine as something on the same level as Legacy, but if that's not the intention I can move it back to existing legacy Yamls. |
7929b8d
to
7e6138c
Compare
5b96934
to
1572be2
Compare
1572be2
to
6ea7c48
Compare
I've found out reason for failure on Travis. I guess it must be a different version of pgsql driver used by Doctrine. I've kinda fallen into my own trap there, because on purpose I tried to avoid it, remembering that it worked fine without it (using last sequence changed). This causes further challenges, because we have I see two possible solutions (the first one partially done):
|
Preference for 1 here, as the stuff inside |
This is sort of ready for a review, but I'm working on a better way to set proper Storage Handler avoiding this workaround. I think it will be better to make another PR than overwrite this one. The main concept in the alternative approach is to get in In this solution, for now, I'm keeping TMP commits with actual Storage implementations for specific Field Types. // ping @andrerom |
class DoctrineStorage extends Gateway | ||
{ | ||
/** | ||
* @var \eZ\Publish\Core\Persistence\Doctrine\DoctrineConnection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we type hint against the DBAL class? (same for use statements, and for Url below)
Afaik our own here is implementation detail, as it looks like we can optionally remove it once we are back to standard pgsql sequences right?
Closing in favor of #1911 |
We want to be able to use
\Doctrine\DBAL\Connection
for FieldTypes external storage directly.To achieve this, FieldType external storage needs to be injected with
DoctrineStorage
gateway which uses Doctrine instead of Legacy Connection Handler.PR also consists of TMP commits presenting sample implementations, for
Url
andRichText
FieldTypes.The main architecture issue related to this implementation is the fact that
\eZ\Publish\Core\Persistence\Legacy\Content\FieldHandler
uses, common for all FieldTypes, Legacy StorageHandler. This means that it's not enough to just register Doctrine gateway for a given FieldType but alsoFieldHandler
must use properStorageHandler
.To workaround this issue Doctrine
StorageHandler
is injected directly intoDoctrineStorage
(GatewayBasedStorage
) implementation for a specific field. IfGatewayBasedStorage
got explicitly injected withStorageHandler
, then this one is used instead of the one passed byFieldHandler
to get a proper gateway.However, sometimes gateway is injected directly setting incorrect Connection.
To avoid this,
DoctrineStorage
Gateway for a FieldType gets injected directly with proper Connection andsetConnection
is ignored.This solution is far from perfect (hence the "workaround" keyword appears), so let's discuss improvements.
TODO:
\eZ\Publish\Core\Persistence\Legacy\Content\StorageRegistry
to\eZ\Publish\Core\Persistence\Content\StorageRegistry
to reflect this is common for storage engines.\eZ\Publish\Core\Persistence\Legacy\Content\StorageHandler
to\eZ\Publish\Core\Persistence\Legacy\Content\StorageHandler
to extract common part for all storage engines.\Doctrine\DBAL\Connection
with custom wrapper extending it.