#2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI deals only with nodes. This issue does the same for taxonomy and aggregator modules. Fix preprocess and templates to bypass special processing of base fields if the new setting is enabled:
- taxonomy term 'name'
- aggregator feed 'title'
- aggregator feed 'description'
- aggregator feed 'image'
- aggregator item 'title'
- aggregator item 'description'
Solution
Copy everything done in #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI.
Release notes snippet
It is now easier to make taxonomy and aggregator base fields configurable via the field UI due to a mechanism to disable preprocessing of base fields, matching the existing mechanism for node base fields. This a step towards making base field display configurable in Drupal Core and in the meantime there is a contrib module to enable it. These changes are fully back-compatible.
| Comment | File | Size | Author |
|---|---|---|---|
| #60 | entity-base-display-2993642-interdiff-58-60.txt | 3.78 KB | adamps |
| #60 | entity-base-display-2993642-60.patch | 34.62 KB | adamps |
| #58 | entity-base-display-2993642-interdiff-57-58.txt | 7.59 KB | adamps |
| #58 | entity-base-display-2993642-58.patch | 33.64 KB | adamps |
| #57 | entity-base-display-2993642-interdiff-55-57.txt | 3.53 KB | adamps |
Comments
Comment #2
adamps commentedPostponed waiting on agreement for #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI
Comment #3
adamps commentedComment #4
adamps commentedComment #5
adamps commentedComment #6
adamps commentedComment #7
adamps commentedThis is outdated now compared with #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI. Once that finally gets committed, we can make updates here to match.
Comment #8
adamps commentedComment #9
adamps commentedComment #10
jonathanshawComment #11
panchoAre you sure we don't want to get this done consistently in D8, at least until LTS?
This may be some work, but once #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI is committed, it's mainly copy/paste, add/fix tests, fix themes.
Comment #12
jonathanshawPer the IS it is definitely doable in D8, but @AdamPS is not planning to do it as part of his one man initiative here, and no one else has shown much interest; whereas it's straightforward for D9.
Comment #13
panchoI don't think that nobody would be interested. I rather think everybody's waiting for #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI to finally arrive, so we can fix it for all other entities consistently, 1:1. If in the end we should be missing the D8 LTS target (which I'm not excpecting), then we can still move on to D9.
Comment #14
adamps commentedIf someone is keen to work on this in D8 that's great. The patch itself is fairly simple, and the one in #4 just needs a bit of tidy up to match #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI. It also needs tests, CR and so on. In comparison, fixing in D9 would be almost free as part of #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display" as then it doesn't need BC. Anyway I think the IS is fairly clear in case anyone wants to take on the job.
Comment #15
adamps commentedHere is a new version of the patch that matches title.display-2923701-305.patch
I have set this back to a D8 task. Sorry for going round in circles, but I had misunderstood the plan for D9. If I understand correctly, we need to get this fix into D8, then deprecate the old way in D9.
Comment #17
adamps commentedComment #18
adamps commentedNeeds work for tests and CR. If we are quick and get this into D8.7 then can share the same CR as the node one.
For the tests, will have to test a teaser view. On the entity own page, the entity label gets stolen by the title block.
Comment #19
adamps commented@Pancho
It's all done apart from the tests. I would be very happy if you had time to help with that.
Also useful if anyone can review the code.
Comment #20
pancho@AdamPS
Sure, as soon as I’m back from vacations, I will look into what’s missing plus do a first code review.
I’m not assigning as everyone who gets to it earlier, is welcome!
Comment #21
panchoCurrently working on the tests.
Comment #22
panchoHere are the tests. Please review whether everything works the way it was meant to be.
Comment #23
adamps commentedGreat thanks @Pancho I will review.
Here is an only tests version of your patch to confirm the tests fail without the patch
Comment #24
panchoGood idea. Indeed I wasn't 100% sure we're getting the title/name fields right, neither am I on #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI which hardly tests the title field at all.
I was also unsure whether we're allowed to combine the three quite similar helper modules
aggregator_feed_display_configurable_testandtaxonomy_term_display_configurable_testwithnode_display_configurable_testinto a single one. Finally, we opted for a single 'enable_base_field_custom_preprocess_skipping' flag.I guess we're too late for D8.7, right?
Comment #26
panchoWhile the tests should be properly testing the impact of the toggle, I'm a bit disappointed to see the tests aren't specific enough. :/
TermDisplayConfigurableTest fails in line 55 with an exception, but shouldn't it fail on the assertions in line 48 or 49?
Even worse, FeedDisplayConfigurableTest doesn't fail at all. Or should it?
I need to figure out better how we're expecting things to be today vs. after the patch. Finally, out-of-the-box behavior shouldn't change at all.
Comment #27
adamps commentedTrue, fair point. But there we had some other fields we could test on and here we don't.
Probably, although the committers are allowed to cherry pick. True, normally that's only for bugs, but we could see if they could view this as an extension to #2923701. I think it would be easier for the community to understand if all entities come in the same release and CR. Anyway we need to get it committed to D8.8 before worrying about D8.7:-).
@Pancho:
@Adam #18:
Yes it's tricky. You are seeing #2941208: Title formatting broken due to flawed EntityViewController->buildTitle scenario 2. Currently Core has no way to disable the "title stealing" on the entity own page. So the only option is to test viewing of the entity indirectly. It could be a node with an entity reference to taxonomy with formatter "rendered entity", or it could be a view of taxonomy with "Show: Taxonomy term". Once you have tests like that it should all work as you expect:
I like the way you have done it. It's easier for us working on patches if you can leave node_display_configurable_test as it is because some other issues have patches that make changes to that file.
Comment #28
adamps commentedPS If you have time to review some other issues that would be very useful thanks.
Comment #29
panchoOuch, I missed that hint. Indeed that is what we should be doing. Reassigning to rework the tests. I will also take a look at the other two issues.
Comment #30
adamps commented@Pancho, yes I have had a few "ouch" moments on this work. Sure it will be a bit harder, but hopefully not too much work.
I can't do this whole area all by myself so I will be very happy if you can finish the issue. If you are not going to work on it then please can you un-assign yourself in case someone else wants to do it?
Comment #31
adamps commentedI guess you have moved on Pancho so I will have a go.
Comment #32
adamps commentedChanged the taxonomy term part to use a view. Not yet done aggregator.
Comment #33
adamps commentedComment #35
adamps commentedHere is the full patch including aggregator
Comment #36
adamps commentedDone CR
Comment #37
adamps commentedOK I think that's done. Please can somebody from the community review and set RTBC? NB only the tests have changed.
Comment #38
jonathanshawI edited the CR very slightly for clarity. Fix & tests look good to me.
Comment #39
lauriiiI think the code change itself is fine. I don't think this patch makes it clear enough that users are expected to make changes before Drupal 9. The patch doesn't mark anything deprecated and doesn't trigger any warnings.
Comment #40
jonathanshaw@lauriii Thanks for the feedback.
The only change the patch expects users to make before D9 is explained in the CR in this way:
However, I'm guessing this is NOT you're concern. I'm imagining you're thinking that maybe we want to remove these special variables altogether in D9, and you're concerned that we're not properly warning developers about this.
This is a relevant concern, as ultimately we are building towards #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display". The meta issue #2353867: [META] Expose Title and other base fields in Manage Display explains the sequence of steps necessary to get that stage.
The key point for this issue though is that:
1) This issue does nothing for taxonomy and aggregate that has not already been done for node in #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI; this issue simples makes core intenally consistent, and this is worth doing now even if the solution already committed for node is imperfect.
2) If we need to find a way to deprecate or warn about the use of (now optional) variables being supplied to templates, we should create a follow-up issue to figure out how to do that and apply it not only to taxonomy and aggregate but also to node. This is a similar approach to that you recently requested in #2993647: Correctly determine when to display fields as inline where you asked for a follow-up issue to establish how to deprecate templates.
Therefore I'm tentatively suggesting this should be be RTBC; if you concur I will create 2 follow-ups: one to establish a policy on deprecating variables supplied to templates, one to implement it for these base fields.
Comment #41
adamps commentedI think @laurii has a good point that the todo comments specifically mention code to be removed in D9, yet nothing has been deprecated. We are still quite far from doing any deprecation so this is misleading. I will adjust the comments to remove the specific reference to D9 in the same way that we did on another related issue recently. The new comments will say something like "code will eventually be removed".
Personally I don't favour any more new issues relating to deprecation at this stage because the actual deprecation is so far away and any discussion now would be highly speculative. We are in stage A "preparation". Stage B will add the option to core to enable manage display. Finally stage C "deprecation" will drop support for the old way, remove the option and manage display is always on (hooks can override). So the real challenge will be "how to deprecate a GUI config option". The template, variable and so on will naturally go away once the config option goes away.
Comment #42
adamps commentedNew patch removes specific mention of D9. I also fixed the exact same comment for node.html that was added in the related issue #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI.
Comment #43
jonathanshawComment #46
adamps commentedRandom fail
Comment #47
plachThe patch code looks good to me, aside from a few non-blocking issues (see review below), however I was expecting to see more entity types covered by this patch.
Specifically I was expecting:
aggregator itemblock content(although I can imagine this might be tricky)commentCan we at least update the IS to explain the rationale behind not addressing those? Given that we have the node part of this already in and that this has a BC-layer in place, I think it should be possible to commit the patch during the alpha window, but we need to make sure core is in a consistent state once beta lands.
For this reason we should either document why it's ok not to convert those entity types or update the patch to handle them.
separatewhat? :)hook_entity_type_build()should be used to provide new entity type definitions, not to alter existing ones. For that we havehook_entity_type_alter(). We need to update the CRs (also the node one) to reflect this.===Wrong group
I'd add an assertion in both cases that the label itself does not exists in the page.
Unused
Wrong PHP doc and
@group.Comment #48
adamps commentedMany thanks @plach
I have looked and I agree you are right. There is no rationale for not addressing those - just no one noticed it is needed. Fixing this will take some time, maybe tight for D8.7. It would also double the size of the patch which is already fairly large. So it might make sense to add just aggregator item into this issue and alter the title/CR so that this issue covers taxonomy+aggregator. Then we can have another issue for comment/block. What do you think?
New patch fixes the other comments. Well spotted, comments all done except for:
2. According to my reading of the descriptions of those functions, the current code is correct. The comment for
hook_entity_type_build()says "Modules may implement this hook to add information to defined entity types," The comment forhook_entity_type_alter()says "Do not use this hook to add information to entity types, unless one of the following is true.." and none of the 3 cases applies here.5. Done for taxonomy but it's not possible for aggregator because the label is present elsewhere on the page:
Comment #49
adamps commentedNew patch adds aggregator item. It's a bit strange because I can't find the "Manage Display" UI in the GUI and there isn't any default config for aggregator_item.aggregator_item.default so I had to write the tests in a slightly different way.
I have updated the IS so this issue covers taxonomy and aggregator modules. Please let me know if it's OK to use separate issues. If so, I will raise a separate issue for the other modules and update the CR.
Comment #50
plachIt's ok to address the other modules in separate issues, let's hope we can get that ready before beta as well, thanks!
Comment #51
adamps commentedThanks @plach.
I have raised #3090187: Mechanism to disable preprocessing of base fields in comment entity type so they can be configured via the field UI for the comment and custom block entity types. I'll see what I can do to get it ready for beta.
I have updated the CR to be correct for this issue. If we get the other one into the same release then I will update the one CR to cover both issues. If not then I'll create a new CR.
Comment #53
adamps commentedComment #55
adamps commentedComment #57
adamps commentedComment #58
adamps commentedLatest patch includes 3 more aggregator fields.
Comment #60
adamps commentedComment #61
adamps commentedOK this is now ready for community review then set to RTBC please.
Comment #62
jonathanshawHeroic work, Adam.
Weight 2 is used for image above; not sure if this matters.
Comment #63
adamps commentedThanks @jonathanshaw
This patch doesn't alter the weights in
aggregator.moduleit just wraps code in if statements. The weights are different for the two different entities: item and feed.Comment #64
jonathanshawAh, of course.
Comment #65
plachI agree with @lauriii that we need to find a way to mark the stuff that is meant to be removed in #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display" as deprecated and warn users about it. I don't think it will be possible to remove from D9 code that was not deprecated in 8.8, worst case it'll happen in D10.
Anyway, given that the corresponding node changes are already committed, I don't think we have good reasons to hold up this improvement. The latest patch looks good to me, thanks!
Comment #69
plachApplied the following diff and committed/pushed 9451d02 to 9.0.x and friends. Thanks!
Comment #70
plachPublished the CR.
Comment #71
plachPlease let's add a release notes snippet to the IS.
Comment #72
adamps commentedGreat thanks @plach. I added the release note snippet.
I would be very interested to discuss the deprecation strategy. I don't believe that we can deprecate anything yet. The special handling of base fields is undesirable in the long term, but for now it's the default approach in Drupal Core. Currently the alternative preferred approach requires a Contrib module.
I believe the sequence of events that allows for deprecation following with the current Drupal policy is as described in the parent #2353867: [META] Expose Title and other base fields in Manage Display:
Does this make sense? Do you see any better way?
Comment #76
wim leersAFAICT this broke
9.0.xHEAD: https://www.drupal.org/pift-ci-job/1461889, all my recent patches are failing. Ah … literally 4 minutes ago, https://git.drupalcode.org/project/drupal/commit/49891d0 was pushed to fix that 🥳Comment #77
wim leersI … don't know how I managed to credit Alex Pott without clicking anything. I guess I cross-posted?
Comment #78
jonathan1055 commentedThe commits in #74 have removed
Core: 8.xfrom the new test module's .info.yml. So now when I run a test for my contrib module at core 8.9 on Drupal.org or Travis, every test fails withI was alerted to this by Travis cron run an hour ago. See manual test run https://www.drupal.org/pift-ci-job/1462019
This is caused by the check in InfoParserDynamic parse()
https://git.drupalcode.org/project/drupal/blob/8.9.x/core/lib/Drupal/Cor...
Could you explain the reason for deleting the "core 8.x' line? Currently all my contrib testing at 8.9 is broken and I don't think my module is unique in this. Hopefully there is a good solution. Thanks.
Jonathan
Comment #80
plach@jonathan1055:
Thanks for the heads up, I think the previous fix was meant to be applied only to 9.0.x. I just reverted it on 8.9.x, which should start working again now.
Comment #81
jonathan1055 commentedThanks @plach, yes it did look like an incorrect deletion of that line. I have just re-run the 8.9 tests on Drupal.org and Travis, and all is back to normal, all passing. Auto e-mail alerts for test failures are a great thing.
Jonathan
Comment #82
xjmChecked with @plach; this change is non-disruptive and therefore more of a release highlight.