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
merged 12 commits into from Jun 21, 2017

Conversation

4 participants
@alongosz
Copy link
Member

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 alongosz:ezp-26885-ft-ext-storage-gw-changes branch 3 times, most recently from 95cb22c to 424b4a2 May 15, 2017

@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 alongosz:ezp-26885-ft-ext-storage-gw-changes branch 3 times, most recently from ca2da9e to a674bff May 17, 2017

@alongosz

This comment has been minimized.

Copy link
Member Author

alongosz commented May 22, 2017

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

@alongosz

This comment has been minimized.

Copy link
Member Author

alongosz commented May 22, 2017

@kore

This comment has been minimized.

Copy link
Contributor

kore commented Jun 19, 2017

+1

@andrerom
Copy link
Member

andrerom left a comment

+1, but some inline nitpicks to fix

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

This comment has been minimized.

@andrerom

andrerom Jun 19, 2017

Member

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

This comment has been minimized.

@andrerom

andrerom Jun 19, 2017

Member

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

This comment has been minimized.

@andrerom

andrerom Jun 19, 2017

Member

similar comment here

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

This comment has been minimized.

@andrerom

andrerom Jun 19, 2017

Member

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}

This comment has been minimized.

@andrerom

andrerom Jun 19, 2017

Member

6.11, same everywhere else in this PR

@andrerom

This comment has been minimized.

Copy link
Member

andrerom commented Jun 19, 2017

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 alongosz:ezp-26885-ft-ext-storage-gw-changes branch from a674bff to cec4b56 Jun 20, 2017

## Changes

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

This comment has been minimized.

@andrerom

andrerom Jun 20, 2017

Member

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?

This comment has been minimized.

@alongosz

alongosz Jun 20, 2017

Author Member

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

This comment has been minimized.

@andrerom

andrerom Jun 20, 2017

Member

yes I think so

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

This comment has been minimized.

@alongosz

alongosz Jun 20, 2017

Author Member

Done, all docs in 13a9dc2

@alongosz alongosz force-pushed the alongosz:ezp-26885-ft-ext-storage-gw-changes branch from cec4b56 to 13a9dc2 Jun 20, 2017

## Deprecations

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

This comment has been minimized.

@andrerom

andrerom Jun 20, 2017

Member

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

This comment has been minimized.

@alongosz

alongosz Jun 20, 2017

Author Member

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.

This comment has been minimized.

@alongosz

alongosz Jun 20, 2017

Author Member

Amended in a6d83a7

@alongosz alongosz force-pushed the alongosz:ezp-26885-ft-ext-storage-gw-changes branch from 23722a4 to a6d83a7 Jun 20, 2017

@andrerom

This comment has been minimized.

Copy link
Member

andrerom commented Jun 21, 2017

Great work @alongosz, merging :)

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

@andrerom andrerom merged commit 9f5f9b2 into ezsystems:master Jun 21, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
ezrobot/phpcsfixer Code review by ezrobot
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.