Problem/Motivation
The split between Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem
and Drupal\entity_reference\ConfigurableEntityReferenceItem
, one being swapped with the other as implementing the 'entity_reference' field type when entity_reference/module is enabled :
- Makes no sense now that all the "extended features" provided by the module (widgets, formatters, selection plugins) progressively made their way into core. The split is now purley artifical, the Core class provides a full-features field type that just omits the methods allowing it to be used for configurable fields in Field UI, the other one just adds the UI methods.
- Only adds major confusion (two classes for a field type, which one runs depends on enabled modules) and maintainance burden for an already complex field type :-)
- Is broken, since entity_reference.module contains housekeeping code for configurable e_r fields, and those can exist without e_r.module (just can't be created in Field UI, but can be shipped by profile / module config)
Proposed resolution
- Remove
Drupal\entity_reference\ConfigurableEntityReferenceItem
in favour ofDrupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem
. - Move or merge
Drupal\entity_reference\ConfigurableEntityReferenceItem
methods intoDrupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem
. - Move all functionality of
entity_reference
from the module into core or other appropriate core modules. - Keep the module empty, disabled and hidden in codebase until 8.1.x when will be removed in #2552139: Remove entity_reference module from codebase.
Remaining tasks
- Needs framework manager review: http://cgit.drupalcode.org/drupal/tree/core/MAINTAINERS.txt means getting feedback from effulgentsia, catch, or alexpott
- Remove the empty Not before 9.x, we need to keep the module with the empty BC classes during the 8.x lifetime.entity_reference
module from code base in 8.1.x, issue #2552139: Remove entity_reference module from codebase.
User interface changes
None.
API changes
- A bunch of tests and modules won't have to depend on 'entity_reference' module anymore
- Contrib modules that extend ConfigurableEntityReferenceItem will have to extend the base one instead
Beta phase evaluation
Issue category | Task because it makes the core codebase more clear |
---|---|
Issue priority | Major because removes an inconsistency that creates confusion. |
Prioritized changes | The main goal of this issue is moving code in the right place |
Disruption | Contrib modules that extend ConfigurableEntityReferenceItem will need to extend EntityReferenceItem instead. An upgrade path is required for existing configuration that depends on entity reference plugins. |
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#189 | interdiff.txt | 2.17 KB | amateescu |
#189 | 2429191-189.patch | 150.22 KB | amateescu |
#187 | interdiff.txt | 782 bytes | claudiu.cristea |
#187 | deprecate-2429191-187.patch | 150.48 KB | claudiu.cristea |
#154 | 2429191-154.patch | 141.63 KB | claudiu.cristea |
Comments
Comment #1
amateescu CreditAttribution: amateescu commentedRIP e_r.module, you will be missed!
Comment #3
jibranWe can remove this too from MAINTAINERS.txt. :P
Comment #4
yched CreditAttribution: yched commentedOMG so much yay.
As a side note, though - ER is a topic in itself, it would be nice to keep an "entity reference field" or something in MAINTAINERS.txt, rather than simply merging it in the "field system" component.
Comment #5
yched CreditAttribution: yched commentedOpened #2438267: Create an "EntityReference system" component
Comment #6
amateescu CreditAttribution: amateescu commentedRerolled on top of #2436835-28: Unable to create config schema for entity type specific entity reference selection plugin. (which also needs a review :)). The schema fixes from that issue should also fix the failures here.
Also, less sensational 3AM issue title :/
Comment #8
amateescu CreditAttribution: amateescu commentedHeh, of course it doesn't apply, here's a combined patch.
Comment #10
BerdirBut...but... the old title was awesome ;)
See also the recent discussion in the remove taxonomy term reference field issue on field vs. storage setting.
I'd argue this belongs in field.module, not system?
The config entities are provided by field.module, not core.
This is exclusively used in tests. I don't think there's going to be enough code to dynamically create ER fields to keep this as a public API. Test trait?
That's.. weird ;) But same, why not move this to views.module?
Comment #11
andypostfor 10.3 trait is better like #2357199: Consider CommentManagerInterface::addDefaultField() as deprecated and remove in favour of CommentTestTrait
Comment #12
amateescu CreditAttribution: amateescu commentedLet's wait for #2436835: Unable to create config schema for entity type specific entity reference selection plugin. which should include the schema fixes.
Comment #13
amateescu CreditAttribution: amateescu commented@vasike opened #2452619: Move entity_reference_create_field function to EntityReferenceTestTrait for #10.3 :)
Comment #14
alexpottIs this code used? You can't change the the target_type through the UI. Shouldn't we just prevent changing it?
Comment #15
alexpottThe blocking issue has landed.
Comment #16
amateescu CreditAttribution: amateescu commentedRestoring the original titile.. by popular demand :D
#14, you can change the target type in the UI when the field doesn't have any data.
#10.1: Yep, that has to be dealt with at some point, that's why put a @todo with a pointer there.
#10.2: Addressed in this reroll. It was quite hard to reroll this on top of the recent changes so I can't provide an interdiff :/
#10.3: We now have a dedicated issue for that.
#10.4: Do you mean to just move the code but keep that function name? Because the provider for the ER field is still 'core' :)
This patch is rolled on top of #2452619: Move entity_reference_create_field function to EntityReferenceTestTrait so it won't apply until that issue gets in. Leaving at NW for this reason.
Comment #17
Berdir10.4 yeah, I guess so. surprised that we have no other example yet with all the stuff we moved into core, but I guess all those field types didn't have special views integration. The only other option I see is to put it right into views_field_default_views_data(), which is always called. That might actually not be such a stupid idea?
Comment #18
BerdirI guess the difference of that is that it would automatically also run for taxonomy, file/image and other references, that are not explicitly type entity_reference.
There's already an entity_reference_revisions module in contrib, which would then also benefit from it, although it would probably have to customize the relationship a bit.
Comment #19
yched CreditAttribution: yched commentedOddities like core_field_views_data() are artifacts of the current shape of the "views integration for field types" API, which is still very much the CCK D6 version :-/. In an ideal world, it would move to an OO / handler shape, like was done for "views integration for entity types".
Separate issue, though ;-)
Comment #20
amateescu CreditAttribution: amateescu commentedFor now, just a reroll because #2452619: Move entity_reference_create_field function to EntityReferenceTestTrait and #2446511: Add a "preconfigured field options" concept in Field UI went in.
Comment #24
claudiu.cristeaLet's see a simple reroll.
Comment #26
claudiu.cristeaSorry, forgot the new trait.
Comment #28
claudiu.cristeaComment #30
claudiu.cristeaComment #32
claudiu.cristeaNarrowing the test failures.
Comment #34
claudiu.cristeaNot ready. Still needs tests fixing.
Comment #36
amateescu CreditAttribution: amateescu commented@claudiu.cristea, you can also use a patch testing issue for this, otherwise the issue becomes needlessly hard to scan for relevant comments :)
Comment #37
claudiu.cristeaAssigning this to @alexpott, CC @catch for a direction with this issue.
Few days ago, I discussed on IRC with @Berdir on this issue and he recommended me to ask you (@alexpott & @catch) if this can go in 8.0.0. There's some work to do here, not a simple issue, and I want to be sure that we don't waste effort on a task that has no chance to catch 8.0.0.
Overall, I feel that entity reference needs some love before the first 8 stable and I'm willing to help here. There are other unfinished tasks/bugs related to ER open.
Comment #38
webchicknice try.
Comment #39
alexpottThis can go in the framework manager review queue.
Comment #40
claudiu.cristeaThis has to be green.
Entity reference field (and descendants, like image, file) they all need an update path to remove the
target_bundle
setting from field storage config and possibly append it to field config handler settings, intotarget_bundles
array. That's why I've implemented a new update hook,field_update_8001()
, and added test to test this update (\Drupal\system\Tests\Field\Update\FieldSettingsTest
).Note also that Entity Reference module is still kept in code base but empty, with no functionality and we have to remove it in a separate issue. I will open a new issue for that.
Comment #41
claudiu.cristeaOpened #2552139: Remove entity_reference module from codebase to remove entity_reference module from codebase in 8.1.x.
Comment #42
cilefen CreditAttribution: cilefen commentedCan someone indicate in the beta evaluation which prioritized change type this is?:
https://www.drupal.org/core/beta-changes#prioritized
Comment #43
yched CreditAttribution: yched commentedWondering about field_update_8001() :
should be 'target_bundle' ?
That line shouldn't be needed, the !empty() in the next line should account for the case $handler_settings is empty / NULL (empty($null['foo']) is TRUE)
If the value is neither an array nor a string, then we'll be looping an all fields just to do "continue" on each one. This check (if needed at all ? can it really happen that it's not empty and neither an array nor a string ?) could move to the if() wrapping the foreach() ?
Not sure how we handle modules disappearing from the codebase, but AFAICT by looking at ModuleInstaller::uninstall(), this will do nothing if the module cannot be found in the codebase (first if() in the method)
Shouldn't we just directly remove the entry from the core.extension config ?
Comment #44
claudiu.cristea@yched,
I don't think we can remove the module from codebase right now because there are update tests that have the module in the list and enabled (from D8 dumps) and those tests will crash because are not able to find the code in the code base. The patch is not removing the module, is only leaving an empty module with no functionality and disable it. Anyway, I'm not very sure that removing from core.extension will not work.
Comment #45
yched CreditAttribution: yched commentedSure, but that's only because the #2552139: Remove entity_reference module from codebase part is temporarliy deferred to a later step ? Once that is done, sites going from beta14 to beta15 (or whatever depending on when this gets in) will run the update while e_r.module is not in the codebase anymore, and the code in the update as it currently stands will do nothing ?
Comment #46
BerdirThe problem is this:
Let's assume this scenario:
1. We commit this now including this upgrade path.
2. You run the updates to the next beta, the module is uninstalled and everything works.
3. Later on, lets say in 8.1, we remove the module left-overs from the system.
Now, someone, for some reason, updates a site directly from beta13 to 8.1. Then he will run into the same problem as we have right now.
That's the main reason for why update functions are so complex. You never know from which version someone is updated to what, they need to work for all possible cases. And the best way to do that is to work with as low-level API's as possible and avoid any hooks/events that you can't control.
That said, we actually discussed on the d8 criticals hangout last friday about exactly such a scenario: Whether we want to special case beta updates and not official support a direct update from betaX to 8.0+. This would be a good reason for that. At the same time, we're going to survive carrying around a hidden, empty entity_reference.info.yml file.
Comment #47
claudiu.cristea#43.1: Moved as
system_update_8004()
.#43.2-5: Removed the part that copies
target_bundle
over handler settingstarget_bundles
.#43.6, #45, #46: Using config API to uninstall.
Also in
system_update_8004()
I'm processing now module dependencies and type provider values.Comment #49
claudiu.cristeaThese tests are passing locally. I don't understand why are failing here.
Comment #51
claudiu.cristeaComment #54
claudiu.cristeaReroll.
Comment #55
claudiu.cristeaComment #57
claudiu.cristeaComment #60
claudiu.cristeaRerolled.
Comment #62
claudiu.cristeaFixed the new test location.
Comment #65
nlisgo CreditAttribution: nlisgo commentedComment #66
nlisgo CreditAttribution: nlisgo commentedComment #68
claudiu.cristeaThe reroll is not straight. #66 doesn't take into account changes from 7a25f513f5b74d7fbc29b95b7de2fc88334533f4.
Comment #69
claudiu.cristeaTagging.
Comment #70
nlisgo CreditAttribution: nlisgo commentedThanks @claudiu.cristea I should have noticed that from the size of the patch.
Comment #71
claudiu.cristeaFix tag.
Comment #72
yched CreditAttribution: yched commentedReopened #2064191: Fix the 'target_bundle' field setting - 'target_bundles' are not validated when entity_reference is enabled and posted a patch over there, to try to get that part cleaned up.
As I noted there, this part of the patch here is incorrect :
'handler_settings' is a Field-level setting, we can't access it in propertyDefinitions(), where all we have is a FieldStorageDefinition.
Comment #73
yched CreditAttribution: yched commentedThat would be *very* nice to get this in before RC :-)
Now that #2064191: Fix the 'target_bundle' field setting - 'target_bundles' are not validated when entity_reference is enabled is in, that should be mostly about moving code around with no logic change, right ?
Comment #74
claudiu.cristea@yched, I'll try to rework this tomorrow. It would be nice if we can have a positive sign on this from the core committers.
Comment #75
webchickYou still need a (actual) beta evaluation in order to get said sign-off.
Comment #76
claudiu.cristeahere we go. Thank you @yched for hints.
Comment #78
jibranComment #79
claudiu.cristeaRerolled.
Comment #82
claudiu.cristeaFixed IS. Added Beta Evaluation.
Comment #83
yched CreditAttribution: yched commentedThanks for the awesome work, @claudiu.cristea !
1st pass at reviewing, I only looked at the "peripherals" for now (not the actual e_r code being moved around)
Nit : move to [ ... ] short syntax ?
We shouldn't be adding orphaned @todos, we should either remove it or open an issue and link to it.
Why is this change needed ? That seems like an API break ?
That looks unrelated ?
Class name is a bit vague :-)
As mentioned by @dawehner in #2064191-55: Fix the 'target_bundle' field setting - 'target_bundles' are not validated when entity_reference is enabled, the test shouldn't use the APIs to adjust the content of the config before running the updgrades.
We should either
- put our test fixtures in an additional dump file (like for example LocalActionsAndTasksConvertedIntoBlocksUpdateTest does),
- or simply base our test on the content of drupal-8.bare.standard.php.gz (frozen dump based on beta12)
The latter is way simpler and largely good enough IMO, that dump contains configurable e_r fields we can test (node.article.field_tags for example)
See for example EntityReferenceTargetBundleUpdateTest
After #2064191: Fix the 'target_bundle' field setting - 'target_bundles' are not validated when entity_reference is enabled, those parts are handled in a different update, and tested by a different test.
Arguably this would belong to field.module :
- e_r module was about configurable fields and required field.module
- the update of the field config only makes sense if field.module is enabled
Ideally that should be shipped in views.module instead of system.
Nit : would need parenthesis around the == check.
(also, that would be best as === IMO)
Those are not reflected in the help text added to field_help() ?
Nit : would rather belong to field_ui.module ?
Comment #84
yched CreditAttribution: yched commentedAlmost done, but need to run, here's what I have for a 2nd part :
Minor : this would logically go above the code block where we add another constraint (no need to loop over that one)
This method is faitly different from what it used to be in ConfigurableEntityReferenceItem, wondering why ?
Why the visibility change ?
Nitpick : s/field/field type
Comment #85
claudiu.cristeafiled_update_8001
. I renamed the class to a genericFieldUpdateTest
now we can add there future tests for field -- field_update_N()field_tags
for testing. It works.views.views.inc
.ConfigurableEntityReferenceItem
version because that is in place right now and works as expected. Maybe @amateescu knows more on this.Comment #87
yched CreditAttribution: yched commented@claudiu.cristea : Thanks !
Meanwhile, I finished reviewing #79, no remarks left :-)
Remarks below are about the interdiff in #85
It still needs to be called core_field_default_views_data(), since it's a "pseudo-hook / magic callback" (probably one of the last in core), called on the provider of the field type - in this case, 'core'.
Still makes sense IMO that views.module's views.views.inc provides integration code for the field types provided by core.
That probably explains the fails.
Clarity nitpick : can we start those comments with "Check that [foo is bar]" ? Helps a lot when visually parsing what the test does :-)
Comment #88
yched CreditAttribution: yched commentedThen I guess the last question is : at this point, what prevents us from removing entity_ref.module completely ? :-)
Also, @amateescu :
The review points in #83.3 and #84.2 seem to be about your earlier versions of the patch. @claudiu.cristea reverted them in #85, but maybe we missed something ?
Comment #89
yched CreditAttribution: yched commentedExpanded the motivations in the IS a bit.
Comment #90
klausiGreat, I love the idea that we can get rid of entityreference module!
Since we are in API freeze we cannot just remove classes like this, since that would break contrib modules. This class and all others from entityreference module need to stay as empty classes that just extend the one from Core now. Except for test classes.
And even in 8.1.x we cannot remove those classes, so the entire removal of the module must be postponed to Drupal 9. Otherwise we make contrib developers very angry :-)
Comment #91
jibran@klausi that is why it has Needs framework manager review tag :). I think @Berdir has a script which renames the module so that can be helpful here but none the less good points.
As DER maintainer this is disruptive but I only have to change some use statements and it'll be good as new :D.
I'm strongly +1 for this issue.
Comment #92
yched CreditAttribution: yched commented@klausi : thing is, we cannot keep the class for BC without also keeping an entity_reference.module that can be enabled (for the class to be found by the autoloader)
Since we wouldn't want people to see it in the module admin page and wonder what it does (it does nothing), that would mean making it hidden *and* required.
Comment #94
claudiu.cristeaComment #95
claudiu.cristea@yched,
I tried this once. All the update tests will fail because you import a DB snapshot of beta12 and inside that a Drupal instance where the entity_reference module is enabled. But in the same time the module is missing from the codebase. That shows a very angry
drupal_get_filename()
:)Comment #98
claudiu.cristeaThe old bot :(
Comment #99
BerdirYes, removing the module is painful for existing sites.
I don't think we need to make the module required, just keep it around as hidden so that existing sites don't break.
Comment #100
claudiu.cristeaYou can see the failures here https://www.drupal.org/node/2274167?page=1#comment-10405883
Comment #101
yched CreditAttribution: yched commentedThat was if we wanted to keep the Item class for BC (if we keep the module anyway, we might as well do that ?). If a contrib module uses the class (and thus requires the module), but the module is hidden, you're in a deadlock ?
Thus I was thinking hidden + required (always enabled, problem disappears) ?
Comment #102
catchIf it's hidden and a dependency I'd expect core to enable it? If that doesn't work would be a bug.
Only thing you can't easily do when it's hidden is uninstall.
Comment #103
yched CreditAttribution: yched commentedIndeed, my bad, you can enable a module that depends on a hidden module, both through admin/modules and drush en.
So I guess that means we should just :
- leave reference/src/ConfigurableEntityReferenceItem.php as an empty @deprecated class extending EntityReferenceItem,
- remove the part of the update (and test) that uninstalls entity_reference.module on existing sites
- Adjust the 'description' in entity_reference.info.yml to something like "Deprecated, all functionality has been moved to Core' (because the current description, 'Provides a field that can reference other entities', would be a lie)
- (Not sure we really need the .module file ?)
And then we can RTBC, commit, and break no BC at all ? :-)
Comment #104
claudiu.cristea@yched, sounds like plan. But still keep it as
hidden: true
, right? Anyway, if a site admin will disable the module we assume that he knows what he is doing, meaning he has no class extendingConfigurableEntityReferenceItem
. Fair enough.Comment #105
claudiu.cristeaOK. That's it.
Comment #106
yched CreditAttribution: yched commentedThanks @claudiu.cristea. Let's do this !
Comment #107
klausiI don't think we should remove amitaibu and amateescu, they should be moved either to the Entity API section or a new section "Entity Reference API".
since we depend on PHP 5.5 now we should use ::class here instead of the class name in a string.
so this class should stay as empty BC class?
can use ::class
So the patch still removes ConfigurableEntityReferenceItem, which we should not do. Let's make it @deprecated extending the Core one and otherwise empty.
I think we should also keep the plugin classes in src/Plugin for the Views integration stuff, with the same @deprecated pattern. We need to stop removing classes and leave them as empty @depreacted wrappers to keep the promise of not breaking contrib code.
Comment #108
claudiu.cristeaOuch! That was a mistake on my side when I built the patch. Sorry.
Comment #109
YesCT CreditAttribution: YesCT commentedrelated to critical #2520526: Calculate configuration entity dependencies on install
there is a beta evaluation, so removing that tag
@claudiu.cristea does that mean you are working on it? if not, I can. (I'm pingable in IRC.)
Comment #110
YesCT CreditAttribution: YesCT commentedadding
Needs framework manager review: http://cgit.drupalcode.org/drupal/tree/core/MAINTAINERS.txt means getting feedback from effulgentsia, catch, or alexpott
to the remaining tasks in the issue summary, for clarity.
Comment #111
yched CreditAttribution: yched commented@klausi :
#107.1 : MAINTAINERS.txt is a tough issue :-) Most of the entity_ref feature is already provided in Core/Field anyway, and Field is the only "component". There is no 'EntityReference" component (not technically in Core, and not in the list of "compnents" in issues).
Like with all the previous field types that were moved from modules to Core/File, this has the drawback of munging the issues under the "Field system" compnent, and making Field API maintainers the only apparent maintainers for them (which, personnaly, doesn't rejoice me ;-)).
But that is an existing issue (there's an issue open for this, can't find it atm), and given the timeframe, I'd rather not derail the patch on this. Also, in this case, it so happens that @amateescu is already a Field API maintainer, and that AFAIK @amitaibu has not really been involved with e_r after the initial patch :-)
So maybe can we punt on that ?
#107.2 .4: Wasn't aware of ::class. So those would become
'#process' => [[EntityReferenceItem::class, 'formProcessMergeParent']]
$item_class = EntityReferenceItem::class;
?
Why not, more readable indeed :-) Let's not block too much on those, though, there are many similar instances in core, and we can mass-simplify them later with a full search on
'\Drupal\.*'
#107.3 : ConfigurableEntityReferenceItem - Oops, I was too quick when reviewing the interdiff #105 :-(
Comment #112
yched CreditAttribution: yched commentedRemoved the "Remaining task : remove the empty entity_reference.module" item from the IS
Comment #113
yched CreditAttribution: yched commentedAnd agreed with @klausi #107 : "keep the plugin classes in src/Plugin for the Views integration stuff, with the same @deprecated pattern". Sucks, but that's the deal.
Comment #114
claudiu.cristeaWorking on it.
Comment #115
YesCT CreditAttribution: YesCT commented@yched
@alexpott added the tag in #39, I was putting it in the summary so we didn't forget about it.
[edit:]
ahh, the third papraphragh in #111 is reinforcing that it is ok to remove the section in maintainers. I see.
Comment #116
yched CreditAttribution: yched commented@YesCT : sure, I didn't modify that :-)
Comment #117
claudiu.cristeaNote on views plugins: I renamed the deprecated plugins annotation labels to mark the also as deprecated. But I admit that I don't understand what happens if two modules are providing the same plugin type and id. And this is the case here, where we want to use those from Views for new views.
Comment #118
klausiWe can't have two plugin classes with the same plugin ID annotation. The annotation should now be provided by the plugin class in Views only. Just keep the empty class around with the @deprecated note.
We have a change here which we cannot avoid: the Views style plugin class for the "entity_reference" plugin is changed. I think that is ok, modules should not hard-code anything to the specific class of a plugin. As long as we keep the old class around we keep compatibility with all modules that specifically extended that class or used it in other ways.
Almost there claudiu :-)
Comment #119
yched CreditAttribution: yched commented+1, the real plugin implementations seen by the system are the new ones, the old classes don't provide plugins anymore, they are just empty shells kept there for contrib modules that might be extending from them for their own plugins,
Also, grammar in the @deprecated comments is a bit off :
"Use the [New\Classname] instead for extending from the [thing]."
Maybe just "Use [new class] instead." ?
Comment #121
claudiu.cristeaComment #122
Wim LeersAddressed all of @klausi's feedback, with one exception:
I don't think we can keep those because the plugin IDs would conflict. I'll leave that to you guys to sort out.
EDIT: ugh, cross-posted :/. Dropped the patch I was uploading, since Claudiu also made additional changes. I caught the problem @klausi pointed out in #118 early as you can see above :)
EDIT: DOUBLE cross-post. Drupal.org, you're super annoying in how incredibly bad you are at resolving cross-posts automatically. Complaining about the file field even after I've already removed them. Gahhhhhhhh.
Comment #123
claudiu.cristeaCan this be fixed on commit? An indent space is missed on the 2nd line :)
Comment #124
claudiu.cristeaHmm... other fixes.
Comment #125
claudiu.cristeaOne more catch.
Comment #127
yched CreditAttribution: yched commentedThanks !
Nitpick, can be fixed on commit :
A bit cryptic (and it's "field type provider" rather than "field storage type provide", which is not really a thing).
Could be simply : "The 'entity_reference' field type is now provided by core." ?
Other than that, yay, back to RTBC if green ?
Comment #131
claudiu.cristea@yched, thank you for the great review and guidance.
Fixed the 8002 docblock.
Comment #132
claudiu.cristeaComment #133
YesCT CreditAttribution: YesCT commentedso the bot runs. [edit: cross post]
Comment #135
Wim LeersComment #137
claudiu.cristeaHEAD has changed.
Comment #138
Wim LeersComment #139
amitaibuGot a ping from @YesCT about this:
> and that AFAIK @amitaibu has not really been involved with e_r after the initial patch :-)
Indeed. As much as I like the idea of having my name in maintainers.txt, I wasn't involved in recent couple of years in ER, so feel free to remove me from there. I'll take credit for the initial ER patches in other occasions ;) Thanks for your hard work folks!
Comment #140
catchGiven there's a bc layer is this feasible for a minor version?
Comment #141
claudiu.cristea@catch, I don't know if we want to go in the stable version with this solution where parts of entity reference are all around.
Comment #142
nlisgo CreditAttribution: nlisgo commentedFeel free to remove my name from the credit list. My only involvement was an attempt at a reroll at #66. My reroll was unsuccessful.
Great work guys!
Comment #143
xjmDiscussed with @alexpott. Thanks for your work on this change! We definitely see the benefits of this change (better developer and site builder experience, less code to maintain, etc.). The fact that the patch retains BC also means that we could make this change now or in a minor version.
However, there are a number of risks with this change:
field_update_8002()
in the patch addresses dependencies in fields, but not in views.For these reasons, I think this change would need an additional upgrade path and upgrade path test, and manual testing of the upgrade path with various installed schema versions and ER-dependent content and configuration. Even then, there would still be a risk of introducing upgrade path bugs that caused problems between earlier betas, beta16, and RC1. Given how close we currently are to a release candidate and that we already have had numerous bugs related to both upgrade paths for these sorts of changes and for configuration dependencies in general, we think that the risk of making this change at this point in 8.0.x is unfortunately too high.
I'd suggest that we add some documentation to the codebase and UI about the state of the module for 8.0.x (could be an rc target issue). @alexpott and I agreed that we should then pursue this change in 8.1.x, once we've had more opportunity to discover and resolve issues related to these sorts of upgrade paths and also more time to write and test the upgrade path for this change in particular.
Also retitling, since the current title (while amusing and quite searchable) is not specific and a bit, um, incendiary.
Thanks everyone! And thanks @alexpott for helping review the changes in the patch and this comment.
Comment #144
yched CreditAttribution: yched commented@catch: +1 to what @claudiu.cristea said. Removing the arbitray separation (Core has a full fledged e_r field, but you need an optional module that swaps the implemenation to be able to use it in Field UI) asap would really help cleanup unnecessary config dependencies before they spread all over (see #2520526: Calculate configuration entity dependencies on install that fixes places where they currently miss. Not having to deal with them while we don't actually need that would definitely be simpler)
Also, the current situation is pretty misleading because you *can* actually have configurable e_r fields without e_r.module (through the API or a module's config/default - just you cant use Field UI). So even the simple "e_r.module is for configurable e_r fields" assessment is actually an oversimplifiication that can lead to wrong assumptions and buggy code.
In short : still really in favor of doing this for 8.0.0 :-)
Comment #145
yched CreditAttribution: yched commentedOops - #144 was a reply to @catch #140, crossposted with @xjm #143. Reading.
Comment #146
yched CreditAttribution: yched commentedAw. Really sad that we have to keep this confusion, for the reasons explained in #144 :-(
At any rate, if this doesn't get in 8.0.0, we really need to get #2578249: Some e_r fields get the wrong Selection handler committed (fixes a nasty example of the "you can have configurable e_r fields without e_r.module" confusion I mentioned)
Comment #147
yched CreditAttribution: yched commentedAlso : this argument from #143 is actually incorrect :
The update removes 'entity_ref' as a dependency in *all* config records (fields, views, entity displays, ... whatever else). That's easy, and cannot really lead to more bugs down the road : entity_ref.module is just en empty shell, no-one, ever, has any reason to ever depend on it. Thus IMO the other arguments (might break more things with dependencies down the road) are kind of invalid as well IMO ?
If the premises for the decision in #143 are incorrect, any chance we can reconsider ?
Temptatively setting back to RTBC and "Needs framework manager review". Sorry for the trouble, feel free to kick back if need be.
Comment #148
jibranI agree 100% with @yched. I think framework manager should revisit the decision in the light of #147. @yched counter every point made in #143.
Thanks @amitaibu for all your work and once again thank you for your initial ER port you are awesome see you in OG issue queue fighting with ER modules shortcoming ;-)
Comment #149
xjmHere is the full update hook, for reference.
Comment #150
xjmI disagree; that's not what #143 said. The point is that this change is not risk-free for existing sites, and we have very little time to make the change before RC or to find unexpected repercussions without risk to the RC upgrade path. I'm not saying it's clear-cut -- just that both the benefit and risk are high, which is why @alexpott and I discussed erring on the side of caution.
The point about this causing other dependency issues is worth considering, but I'm not sure it outweighs the risk.
I still don't see how Views ER plugin configuration dependencies are going to get removed in #149. I see it removing module dependencies and updating field storage dependencies.
Comment #151
yched CreditAttribution: yched commented@xjm : the views plugins impacted are a display, row and style plugin, used by a very specific feature of (Core) e_r fields : the ViewsSelection handler, that lets you define referenceable entities by a view rather than by bundles.
Those plugin implementations are moved, but the plugin IDs remain unchanged. So I don't think anything in existing views config records need to be changed ? (other than, no longer needs e_r.module, which the update does)
Comment #152
alexpottI missed the part of the update where all configs which depend on entity reference are being updated.
This needs to be
$config->set('dependencies.module', array_values($dependencies));
otherwise some odd numbers are going to start appearing in config dependency keys.Have we got test coverage of a view that depends on entity reference being updated... it would be great if this view also depended on user so we can test for the bug avoided by doing the
array_values()
above.I still agree with @xjm that this is risky.
Comment #153
claudiu.cristeaComment #154
claudiu.cristeaRerolled and added #152.
Comment #155
claudiu.cristeaPassing for review.
Comment #157
claudiu.cristeaOuch, DrupalCI is lying. That should have failed. Opened a critical #2580293: Patch having test with "PHP Fatal error" is marked as PASSED.
Comment #158
nlisgo CreditAttribution: nlisgo commentedThere are a few instances of a space before the semi-colon.
I have found 8.
Comment #159
yched CreditAttribution: yched commented- Enriched testFieldUpdate8002() with tests for a view using the e_r plugins, checking that the "referenceable entities based on a view" feature still works
- Moved EntityReferenceSettingsTest, that got added ine_r.module meanwhile.
Comment #160
yched CreditAttribution: yched commentedMeh. Didn't intend to leave testFieldUpdate8001() commented out :-/
Comment #165
claudiu.cristeaComment #166
yched CreditAttribution: yched commentedThose fails beat me. The field.storage.node.field_ref_views_select_2429191.yml I provide as a fixture causes a schema error when the recently added field_post_update_save_custom_storage_property() tries to resave it -" Exception thrown while performing a schema update. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException()"
Same error if I completely comment out the field_update_8002() update we're adding here, so it's not the fault of the code in there.
Have to run, hope @claudiu.cristea can find out more :-/
Comment #167
yched CreditAttribution: yched commentedBTW, unrelated to the fails, but to leave clean dependencies, field_update_8002() should rather do
We should roll that in the next patch.
Comment #168
yched CreditAttribution: yched commentedOther than those weird fails, the asserts about the view still working do pass, btw. It's just the post_update that chokes on my test field...
Comment #169
claudiu.cristeaIt's something related to field_post_update_save_custom_storage_property()
Comment #170
claudiu.cristeaJust posting the progress including #158 and #167. Thank you @nlisgo for those findings.
Comment #171
yched CreditAttribution: yched commentedAw. That's because the db created by our fixture file, drupal-8.views_entity_reference_plugins-2429191.php, also needs to contain entries describing the "schema" in the entity.storage_schema.sql k/v store. Kind of a massive drag :-/
Will try to add that.
Comment #172
claudiu.cristeaLet me try, so that you can review.
Comment #173
claudiu.cristeaI did that. Maybe I'm wrong somewhere because still fails :(
Comment #175
yched CreditAttribution: yched commentedOK, that was hell to debug, but the answer was : the fixture also needs to update the "last installed field storage" entry in k/v, otherwise
$field_storage->save() in field_post_update_save_custom_storage_property() will cascade down to SqlContentEntityStorageSchema::updateDedicatedTableSchema() thinking it's a deleted field.
This makes it fairly hard to provide fixtures with fields for update tests...
But well, this should be green.
The fact that views using the plugins provided formerly provided by e_r.module still work after the update is tested in FieldUpdateTest::testFieldUpdate8002()
Comment #176
yched CreditAttribution: yched commentedOops, forgot to mention : interdiff #175 is with #170, I left patch #173 aside.
Comment #178
yched CreditAttribution: yched commentedReroll after #2578249: Some e_r fields get the wrong Selection handler, that already had to move entity_reference_field_config_update() and entity_reference_field_storage_config_presave() into field.module.
Comment #182
jibranmore then 80 chars?
Comment #183
claudiu.cristeaRerolled after #2578559: Have ViewsSelection no longer extend SelectionBase. Fixed #182. Thanks!
Comment #184
jibranLet's fix this before RC.
Comment #187
claudiu.cristeaForgot a use statement.
Comment #188
jibranDoh!!!
Comment #189
amateescu CreditAttribution: amateescu commentedI reviewed the latest patch and I could only find a small problem in the update function: we don't want to update the module of every field type that extends the EntityReferenceItem class, we only need to do it for the 'entity_reference' type :)
As one of the maintainers of this code in D8, I believe that the problems/motivation described in the current issue summary are very real and will cause a great deal of WTFs along with unnecessary future maintenance cost.
Given that the concerns raised in the initial framework/release manager review have been addressed and additional test coverage was added, the benefits of this patch are higher than the risk, IMHO.
Comment #191
alexpottDiscussed with @xjm and @catch. We agreed with @amateescu that doing this now is less risky than trying this in 8.1 or 8.2 and that now we have the extra test coverage around the upgrade path the patch is also less risky to do. Whilst we are in the pre-RC commit freeze maintainers still have discretion therefore committing under that.
Committed 97823b5 and pushed to 8.0.x. Thanks!
Comment #192
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThank you!!
I'm not sure if a change notice is needed since we kept everything needed for BC, but it's probably worth a bit of attention for existing D8 sites so I'll write one tonight if no one beats me to it.
Comment #193
yched CreditAttribution: yched commentedAwesome !!! Thanks all :-)
Comment #194
jibranYay!!! Seems like perfect story we added ER and kind of removed at the same time in Drupal 8.
Comment #195
Wim Leers#194: haha :D
Comment #196
claudiu.cristeaGreat! Thank you @yched, @amateescu, @jibran for not giving up. Also, many thanks to core committers for their decision.
Comment #197
yched CreditAttribution: yched commented@jibran : entity_reference was moved to core, and then it was moved to Core.
Comment #198
fagoWohoo, great!
>Yay!!! Seems like perfect story we added ER and kind of removed at the same time in Drupal 8.
We did even worse things to entity module ;)
Comment #199
claudiu.cristea@jibran, @yched, @fago,
Lucky that Drupal 8 has the longest release cycle ever. We have time to move it back to contrib. LOL :D
Comment #202
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedHere's the change record: https://www.drupal.org/node/2598002
Comment #203
yched CreditAttribution: yched commentedThanks @amateescu : adjusted "classes will be removed in 8.1.0" to "... in Drupal 9", since that's what we wrote in the code (and I don't think we plan on removing deprecated things in minor releases ?)
Comment #204
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedOh, right. Thanks for catching that :)
Comment #205
xjm