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

EZP-26885: Refactor Field Types external storages to inject gateways and connection handler via DI #1985

Merged

Conversation

alongosz
Copy link
Member

@alongosz alongosz commented May 12, 2017

Part 1 of EZP-26885 implementation.

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.

This PR is the first step towards solving EZP-26885. To be able easily inject Doctrine instead of Legacy DatabaseHandler we need to make the latter fully injectable. Up to now, external storage gateway was chosen by context passed by \eZ\Publish\Core\Persistence\Legacy\Content\StorageHandler.

This PR refactors Field Type-specific external storages so they get injected with proper, FT-specific gateways.
Each gateway gets injected with \eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler.
In the future Legacy gateway injected into FT-specific external storage can be replaced with Doctrine gateway which would use \Doctrine\DBAL\Connection.

TODO:

  • Introduce to SPI layer GatewayBasedStorage which refactored FT storages should extend.
  • Introduce to SPI layer StorageGateway to be extended by refactored FT ext. storages gateways.
  • Deprecate \eZ\Publish\Core\FieldType\GatewayBasedStorage which sets and gets gateways from context.
  • Deprecate \eZ\Publish\Core\FieldType\StorageGateway which allows setting connection manually, without DI.
  • Refactor Keyword FT external storage.
  • Refactor BinaryFile and Media FT external storage.
  • Refactor Image FT external storage.
  • Refactor MapLocation FT external storage.
  • Refactor User FT external storage.
  • Refactor Page FT external storage.
  • Refactor RichText FT external storage.
  • Refactor Url FT external storage.
  • Perform manual tests with web app.
  • Make upgrade doc.

@alongosz alongosz changed the title EZP-26885: As a Developer I want to future proof my Field Types by using Doctrine [in external storage] [WIP] EZP-26885: As a Developer I want to future proof my Field Types by using Doctrine [in external storage] May 12, 2017
@alongosz alongosz force-pushed the ezp-26885-ft-ext-storage-gw-changes branch 3 times, most recently from 95cb22c to 424b4a2 Compare May 16, 2017 13:47
@alongosz alongosz changed the title [WIP] EZP-26885: As a Developer I want to future proof my Field Types by using Doctrine [in external storage] EZP-26885: Refactor Field Types external storages to inject gateways and connection handler via DI May 16, 2017
@alongosz alongosz force-pushed the ezp-26885-ft-ext-storage-gw-changes branch 3 times, most recently from ca2da9e to a674bff Compare May 19, 2017 14:49
@alongosz
Copy link
Member Author

Example of actual implementation of DoctrineStorage gateway is available in the PR #1993.
For Keyword FT: 46d5589.

@alongosz alongosz requested review from andrerom and Nattfarinn May 22, 2017 09:10
@alongosz
Copy link
Member Author

review ping @andrerom @kore @Nattfarinn

@kore
Copy link
Contributor

kore commented Jun 19, 2017

+1

Copy link
Contributor

@andrerom andrerom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, but some inline nitpicks to fix

@@ -0,0 +1,166 @@
# Upgrade steps from 6.9 to 6.10
Copy link
Contributor

@andrerom andrerom Jun 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6.10 to 6.11 by now

Abstract base class `eZ\Publish\Core\FieldType\StorageGateway` for the gateway of a Field Type external storage and the
`eZ\Publish\Core\FieldType\StorageGateway::setConnection` method are deprecated.

Extend the `eZ\Publish\SPI\FieldType\StorageGateway` class and inject Database Handler directly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to better signal that the change is not something field types have to do immediately, start the sentence by saying something like:

To prepare your FieldType for future storage engines and avoid using the deprecated abstract, extend the ..

Abstract base class `eZ\Publish\Core\FieldType\GatewayBasedStorage` for Field Type external storage
which uses gateway is deprecated.

Use `eZ\Publish\SPI\FieldType\GatewayBasedStorage` instead and inject external
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar comment here

'%s extends deprecated %s. Extend %s instead',
static::class,
self::class,
\eZ\Publish\SPI\FieldType\GatewayBasedStorage::class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

place in use section to not use FQCN inline

@@ -15,6 +15,8 @@
/**
* Storage gateway base class to be used by FieldType storages.
*
* @deprecated Since 6.10. Use {@link \eZ\Publish\SPI\FieldType\GatewayBasedStorage}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6.11, same everywhere else in this PR

@andrerom
Copy link
Contributor

Another thing, this deprecation should also be mentioned with a point in doc/bc/6.11 with reference to the upgrade doc for further info.

@alongosz alongosz force-pushed the ezp-26885-ft-ext-storage-gw-changes branch from a674bff to cec4b56 Compare June 20, 2017 13:11
## Changes

- EZP-26885: Field Type external storage
- Field Type external storage gets directly injected with a proper external storage gateway.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is misleading isn't it, people will need to migrate as stated in upgrade doc in order for this change to affect them. As in if they stay on old abstract nothing will change or?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I wasn't sure how to indicate this. Maybe I just should keep ## Changes section empty and keep ## Deprecations only?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I think so

we almost always first deprecate, and in a later release change or remove ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, all docs in 13a9dc2

@alongosz alongosz force-pushed the ezp-26885-ft-ext-storage-gw-changes branch from cec4b56 to 13a9dc2 Compare June 20, 2017 15:06
## Deprecations

- EZP-26885: Field Type external storage
- Abstract base class `eZ\Publish\Core\FieldType\StorageGateway` for the gateway of a Field Type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you also list up eZ\Publish\Core\FieldType\GatewayBasedStorage here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry :( Somehow I thought we have only two deprecations in Core. I looked over entire diff and in fact we have 4 in total. Added as a fixup in 23722a4 for easier review.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended in a6d83a7

@alongosz alongosz force-pushed the ezp-26885-ft-ext-storage-gw-changes branch from 23722a4 to a6d83a7 Compare June 20, 2017 20:54
@andrerom
Copy link
Contributor

Great work @alongosz, merging :)

You can now rebase the other one when you have the time ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants