When Drupal displays a field, the template is field.html.twig, which generates block-level markup including optional labels, attributes, and supports multiple values.
For the node title, uid and created fields Drupal supplies an overridden template (e.g. field--node--title.html.twig) that generates simplified inline markup without label or title_attributes.
If the site owner has hooked the node title to setDisplayConfigurable(), then the inline display is incorrect. The label is missing, markup is inline, and the markup might not match normal CSS selectors for fields (for example if the CSS selector specifically matches on div). For the node created field, also the metadata rel="schema:author" is missing.
Solution
Add a '#inline_field' variable to the field templates so that they can distinguish whether they are called in a context where they should return block markup or inline markup.
The detailed rules for inline markup are as follows:
- The page title is always inline.
- The node title, uid and created fields are inline except if
setDisplayConfigurable()has been called. - To preserve back-compatibility, rule 2) only applies if an additional entity type property has been set - reusing the mechanism from #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI.
Workaround
/**
* Implements hook_theme_registry_alter().
*/
function XXX_theme_registry_alter(&$theme_registry) {
// Disable the 'inline' versions of node base field templates to workaround
// https://www.drupal.org/node/2993647.
unset($theme_registry['field__node__title']);
unset($theme_registry['field__node__uid']);
unset($theme_registry['field__node__created']);
}
Release notes snippet
field--node--title.html.twig, field--node--created.html.twig, and field--node--uid.html.twig have been modified to render these fields as they are configured by the site builder for sites that allow configuring the display of these fields. Themes that include these templates should add this change to them as well. See the change record for details.
| Comment | File | Size | Author |
|---|---|---|---|
| #122 | inline-field.2993647-interdiff-119-122.txt | 5.36 KB | adamps |
| #122 | inline-field.2993647-122.patch | 37.58 KB | adamps |
Comments
Comment #2
adamps commentedComment #3
adamps commentedComment #4
adamps commentedHere is a patch, but it must be applied after the patch from #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI. It will show as "failed to apply" on Drupal.org.
Comment #5
adamps commentedPrevious patch was bad. Here is a new patch, which applies on top of title.display-2923701-205.patch.
Comment #6
adamps commentedI have modified the issue summary so that this issue now relates specifically to nodes. The other part of the original problem has been moved into #2941208: Title formatting broken due to flawed EntityViewController->buildTitle. This makes the fix here much simpler and hopefully easy to commit to 8.7.x.
This issue is based on #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI so I have uploaded two patches.
Comment #7
adamps commentedComment #9
adamps commentedFix deprecation notice and add comment.
Comment #10
adamps commentedReminder
Comment #11
adamps commentedI found a problem with quickedit. When a base field is re-rendered after edit, a single field is rendered without first calling
template_preprocess_node. The new patch moves all the inline_field logic intonode_preprocess_field__node. However if you edit the title field from the title block, it's still not fixed, and I can't see any way to fix it without big changes to quickedit. I've added a note for that problem to #2941208: Title formatting broken due to flawed EntityViewController->buildTitleSecondly I have changed the variable name from
#skip_inline_fieldback to#inline_field. In case we do want ever apply the more general patch like #5 then we need to get the name right now.Comment #12
adamps commentedSlight change to make it more general - this makes it easier for contib modules to control the formatting within the page title.
Comment #13
adamps commentedI have created a new release of the Contrib module Manage Display
Thanks to the 3 others who are now following. Please help get this patch committed - you don't have to be an expert to help. If anyone can test that the patch works and makes sense, please set the status to RTBC. This brings the patch to the attention of the core committers - don't worry they will give it a thorough review.
Comment #14
adamps commentedI am now on a break from Drupal.org
Hopefully #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI will get committed soon, in which case I have already prepared the reroll. Please can someone load up inline-field.DELTA_.2993647-12.patch again as inline-field.2993647-XX.patch (XX = next comment number of course).
Setting this to major, as the important feature introduced in #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI doesn't work properly without this patch.
Comment #15
mrpauldriver commentedConfirm that this patch together with manage_display 8.x-1.0-alpha6 is working for me
Comment #17
larowlanUnintended change?
I'm not a huge fan of new undocumented magic array keys
this relies on elements from the other issue? I don't think we can add this without that
this looks like the code from #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI?
are we allowed to make changes to markup in stable?
Comment #18
jonathanshawYes, this depends on #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI.
Looks like @AdamPS introduced this in #12 to make it "easier for contib modules to control the formatting within the page title". Let's hope he can explain the need.
Comment #19
adamps commented@larowlan Thanks for your time to review.
1. This was intended change because the original comment is wrong. The code for RDFa in rdf_preprocess_node puts title metadata into
$variables['title_suffix']. However I can see that fixing that comment is not directly related to this issue, so I could leave it out of the patch if you think that's better.2. Good point - I should definitely have a comment here with @see referring to the related template. That would address "undocumented magic". It would still be an array key, but I can't see any alternative.
3, 4. Yes this depends on #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI. However if you look at inline-field.DELTA_.2993647-12.patch then you can see only the differences specific to this issue.
5. Correct me if I'm wrong, but I believe the purpose of stable is to create a stable base-point for theme developers to that they don't have to track every change to a template. If we put these changes into stable, then we achieve that. If we don't, then theme developers would have to add it themselves.
Comment #20
adamps commentedHere are new patches based on the newer patch in the base patch #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI and including the code change for point 2. in the previous comment.
As before
Comment #22
adamps commentedFixed version...
Comment #23
adamps commentedOK, so I have found a fairly easy workaround
What's more #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display" will automatically fix this bug in an easy way - by waiting until D9 there is no need to maintain back-compatibility.
Therefore I propose we might as well just postpone this issue and fix it the easy way. However if anyone disagrees and feels keen to put the effort in, then they can reawaken this issues.
Comment #24
jonathanshawI believe postponed has to be postponed on something; this should be closed, and someone can reopen if they disagree.
Comment #25
adamps commentedFine, then please for consistency can you do the same for #2993642: Mechanism to disable preprocessing of base fields in taxonomy and aggregator entity types so they can be configured via the field UI?
Comment #26
jonathanshawActually, my bad, if what you're proposing is to leave this to 9.x, then it should be an active issue on that branch I think. Same done for #2993642: Mechanism to disable preprocessing of base fields in taxonomy and aggregator entity types so they can be configured via the field UI.
Comment #27
adamps commentedOK I'm not so sure about active, because it encourages someone to work on it or expect some action here.
If it has to be postponed on something, then let's say it is postponed to early 9.0 dev branch on a decision how to handle #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display". If that issue proceeds as expected, we will then close this one as outdated.
Comment #28
adamps commentedI 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.
Here is a patch that is really simple, fully-BC and requires no template changes. I have just implemented the workaround from the IS.
Comment #30
rodrigoaguileraI have tried the patch and I can confirm it works as expected. I wanted to show the created date of the node with a label and with the patch applied I only had to set the field as configurable in the view mode.
I'd change it to RTBC but I think it might need a change record for people who are setting those fields as configurable and don't expect the markup to change.
Comment #31
rodrigoaguileraPlease review the change record
https://www.drupal.org/node/3043840
The code looks good to me.
Comment #32
adamps commentedThanks @rodrigoaguilera. I adjusted the CR slightly to better match the existing CR for #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI.
We may need to make adjustments depending on the timing. If this fix gets ported back to D8.7 prior to the stable release then we can potentially combine with the existing CR. If not, then perhaps we should change the patch here to use a new property instead of enable_base_field_custom_preprocess_skipping - because otherwise people who have already set the existing property might get an unpleasant surprise when the new behaviour is added in D8.8.
Comment #33
alexpottThe patch is failing tests.
Comment #34
adamps commentedUpdated patch fixes NodeDisplayConfigurableTest. I expect the Media test fail is a random.
Comment #35
jonathanshawComment #37
jonathanshawRandom fail
Comment #38
larowlanTagging for front end framework manager review because of the change from span to div for those fields
Comment #39
adamps commentedThanks @larowlan. NB this fix actually fixes the overall rendered output to be consistent whether
setDisplayConfigurable()is ON or OFF:1) Now
setDisplayConfigurable()OFF2) Now with
setDisplayConfigurable()ON3) After this patch with setDisplayConfigurable() ON
Comment #41
adamps commentedAnother random fail
Comment #43
adamps commentedSo many random fails!
Comment #44
lauriiiThe current approach has some side effects that could be disruptive to themes as well as theming experience. Removing these items from the theme registry seems to completely prevent users from overriding templates using the suggestion matching the theme registry item. So for example, after
field__node__createdhas been removed from theme registry, themes are unable to providefield--node--created.html.twigtemplate. This is also not something we can or should fix because after it gets fixed, this solution also becomes ineffective because Classy and Stable both provide templates using more specific theme suggestions for this template.I think the approach used earlier on this issues (#22) would be less disruptive. Even though markup changes to Stable and Classy are not allowed, that would be a less disruptive approach than what has been taken currently.
Comment #45
adamps commentedThanks @lauriii
Here is a reroll of patch #22.
Comment #47
adamps commentedComment #48
adamps commentedIS and CR have been updated to match the new patch.
Please can someone from the community review this and set RTBC?
Comment #49
adamps commentedCorrected patch after testing with Manage Display module.
Comment #50
jonathanshawLooks good to me.
I like the universality of this approach. The calling context knows the surrounding markup, so it's got responsibility for informing the template about it. This pattern could well be useful beyond these few node fields.
Comment #51
wim leersWouldn't
is_inline_fieldbe clearer? Or evenis_inline, so that it eventually could be generalized for use in non-Entity Field situations?Comment #52
jonathanshaw+1 for is_inline
Comment #53
wim leersThanks for responding so quickly, @jonathanshaw :)
Since you previously RTBC'd this patch and now agree with my suggestion, I'm gonna mark this .
Comment #54
jonathanshawAn easy fix.
Comment #55
adamps commentedComment #56
wim leersExcellent, thanks! I wanted to re-RTBC, but in my final review I found some more problems:
Nit: let's use that third
in_array()parameter for strict comparison. We do that always.There's some shorthand notations ("back-compatibility" and "d9") in this comment that we generally don't use :)
More importantly: if we're going to remove this, shouldn't we be deprecating it in this issue?
for inside span/h1/h2 etcis not as precise as we tend to write comments. How about:for inline elements such as <span>, <h2>, and so on.?Comment #57
jonathanshawThat makes sense. Unfortunately https://www.drupal.org/core/deprecation does not explain how to deprecate a template. Any ideas?
This flag was introduced in a prior issue; I'd suggest the question of how it should be deprecated is out of scope for this issue?
Comment #58
adamps commentedThanks @Wim Leers - new patch fixes comments from #56. I removed the specific reference to D9 because it is seems more likely that the deletions of #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display" won't make it until D10.
We cannot deprecate anything yet. The full sequence of planned steps is given in the parent META issue #2353867: [META] Expose Title and other base fields in Manage Display. Once we have completed #3036862: Expose Title and other base fields in Manage Display in Drupal Core we can eventually deprecate the old way that does not "Expose Title and other base fields in Manage Display in Drupal Core". Then in the next major version we can finally delete the code for the old way.
Comment #59
jonathanshawComment #60
wim leers#58 Thanks for that background information, I was not aware. Thanks for pushing this along! 🙏
Comment #61
lauriiiI do like the current approach more! Thank you!
Maybe this would be a good place to briefly document what is is_inline including intentions behind introducing it. And for better discoverability, we could maybe add @see documentation to templates.
Could we include an explanation on why the title must be always inline?
I have similar concern as #56.2. Making this change would likely not be enough to allow those templates to be removed since users aren't being notified that there's something expected from them. Could we open an issue to discuss how to deprecate templates? We could then add @todo comments to properly deprecate the templates once that issue has been solved.
Comment #62
adamps commentedThanks @lauriii
1. and 2. Done
3. We already have @todo comments referring to the issue that will handle deprecation: #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display". That issue covers deprecation for all of the parts of the parent META issue #2353867: [META] Expose Title and other base fields in Manage Display, which makes sense because the deprecation strategy will be shared. So I propose that the existing @todo comments should stay as they are.
I completely agree. We cannot remove the templates yet because they are still being used. These templates are required so long as we need to support both options: custom preprocessing and
isDisplayConfigurable().So the deprecation strategy that I propose will take some time, but it seems fully valid and the best (only!) idea I have seen so far.
Comment #63
adamps commentedSorry that was the patch from the wrong issue - here is the correct one.
Comment #64
jonathanshawComment #67
adamps commentedRandom fail
Comment #68
adamps commentedThis patch has been RTBC for 5 months. It has been reviewed by the relevant experts and all comments have been addressed. Please, please can someone commit it or explain what more needs to be done before commit?
Comment #70
adamps commentedRandom fail
Comment #71
nick_vhMaybe good feedback, but at Dropsolid we are waiting anxiously on these commits to happen. Ideally before 9 gets released.
Comment #73
xjmComment #74
adamps commentedThe frontend framework manager review already happened in #44. Would be great to get this committed.
Comment #75
jonathanshawMaybe @xjm wanted the frontend framework manager review for #61.3, but that doesn't directly affect this patch.
Comment #76
xjmI'm tagging it for frontend framework manager review to validate that the improvements described in #62 and implemented in #63 address his feedback. This request for his signoff is part of trying to get this issue committed. Thanks!
Comment #77
adamps commentedGreat thanks for your time @xjm
Comment #78
lauriiiMaybe I'm missing something but how are we going to be able to remove the inline template for titles?
I still had the concern that we should deprecate these templates for us to be able to delete them eventually. Maybe we could use the Twig deprecated tag for this https://twig.symfony.com/doc/2.x/tags/deprecated.html. I think it would be fine to do this in a follow-up that would happen between this issue and #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display". Instead of marking these to be deleted as part of that issue, let's reference the new follow-up.
I assume we will have to remove the is_inline variable eventually too. Let's open another follow-up to figure out how to deprecate that.
Comment #79
adamps commentedThanks @lauriii
Good point.
Your comments 2-4 are similar to your previous ones in #61 that I tried to answer in #62. Sorry I guess I must not have explained very well last time, so I'll try again. If what I say still makes no sense to you then please can we try to chat?
This issue is just one piece in a fairly complex META issue #2353867: [META] Expose Title and other base fields in Manage Display. The deprecation strategy takes each of the pieces together.
Phase A [Current phase]: Core uses custom preprocessing. Contrib can enable isDisplayConfigurable(). We cannot deprecate anything yet as custom preprocessing is still used in Core.
Phase B: Add a GUI option in Core to choose between custom preprocessing or isDisplayConfigurable(). Wait a while then deprecate the custom preprocessing. At this point we can deprecate many things including the templates. I have raised a new issue #3176673: Deprecate non-standard display of title and other base fields.
Phase C: [D10]: Delete the deprecated code.
It's a reasonable suggestion however we already have many @todo comments from other issues within this META issue that reference 3015623, so I assume we ought stick with that for consistency.
Comment #80
adamps commentedComment #82
adamps commentedComment #84
ravi.shankar commentedFixed failed tests of patch #82.
Comment #85
adamps commentedSorry #82 was the patch for a different issue. Try again.
Comment #87
adamps commentedComment #88
jonathanshawBack to @laurii
Comment #89
adamps commentedThanks @jonathanshaw. I think it would be useful to get a clearly documented review from the community. If you are happy with the patch please can you set the status to RTBC?
Comment #90
jonathanshawI RTBC'd in #64, and that still stands, but no one's going to commit without frontend framework manager sign off.
Comment #91
adamps commentedI agree with that. However I worry that the frontend framework manager might wait until issues are RTBC before reviewing them. My interpretation is that you and I are the community; RTBC means we, the community, think it's ready for the maintainers/managers to look at.
Comment #92
jonathanshawComment #95
adamps commentedJust a random fail
Comment #97
jonathanshawRandom
Comment #98
alexpottThis should test for truthiness too.
$variables['element']['#is_page_title'] = FALSEwill pass this check too which would be wrong.I think:
would work.
This is making me wonder if field.html.twig should support
is_inlinetoo.This is the sum total of the test coverage introduced here. The good thing is that the test contains the opposite assertions here proving that BC is maintained.
I'm leaving at rtbc because the change required to fix the if is very small.
Comment #99
alexpottDiscussed with @lauriii. In light of #3144443: Phase out Drupal\Core\Template\Loader\ThemeRegistryLoader I think we should use something like
I think we need to change this test to test all the themes change here so we have test coverage of all the changes.
Comment #100
lauriiiDiscussed #99.1 with @alexpott in more detail and we thought that even though #3144443: Phase out Drupal\Core\Template\Loader\ThemeRegistryLoader is happening, we still prefer using the
Drupal\Core\Template\Loader\ThemeRegistryLoaderhere because it benefits contrib theme authors without too much of a downside. Most of the downsides listed on that issue are specific to usingDrupal\Core\Template\Loader\ThemeRegistryLoaderwith the Twig extend or embed. That issue will likely end up providing an alternative, more explicit way of loading templates from the theme registry.We also briefly discussed the benefits of the current approach over the approach taken in #34. We agreed that the current approach is better because it makes this behavior explicit for front end developers. It also makes sure that any pre-existing overrides don't break as a result of setting
enable_base_field_custom_preprocess_skippingto true.Comment #101
alexpottPatch attached addresses #98 and #99
But leaves one more thing to do which is to fix the test to test Olivero and probably to fix the Olivero theme.
Comment #103
alexpottFixing the deprecation.
Comment #104
adamps commentedMany thanks @lauriii and @alexpott. #103 looks good to me.
Setting to needs work for "test and fix the Olivero theme." I'll get to it as soon as I can but probably not this month so if anyone else is keen please go ahead.
Comment #106
donquixote commentedHello,
It is nice we are trying to fix this, but to me this seems like the wrong approach:
Alternative: field--inline.html.twig
Instead we should simply have a
field--inline.html.twigand a regularfield.html.twig, and then make the distinction on render element level or on theme hook suggestion level.Possible problems and challenges with this idea:
Comment #107
adamps commented@donquixote Thanks for your comment. We did already consider that idea, and in fact you have exactly highlighted the problem we also noticed with it. Backward-compatibility is a big challenge with this issue and the whole META issue #2353867: [META] Expose Title and other base fields in Manage Display. We must care for the majority of sites that don't change their templates and ensure nothing gets worse. If we start invoking the theme
field--inlinein cases that previously usedfieldthen we break sites because custom hooks/templates will no longer be called.The disadvantages you list are only temporary. Once the whole META issue is completed they will all go away becoming much better than now. Eventually we don't want to invoke a different template for those 3 fields instead we want to remove that whole special case and treat them like any other field. So introducing
field--inlinenow actually creates a problem when we want to get rid of it again later. So in D10 when we can remove the deprecated code we will have the perfect solution. Until then it is slightly more complicated but I don't see any alternative.The strategy chosen here has now been reviewed by many key members of the Drupal.org community and they have collectively agreed it is the correct approach.
Comment #108
donquixote commented@AdamPS Thanks for the explanation!
If this is indeed the best or only BC-friendly solution, then I am ok with it for D9.
Where would I learn about the "perfect" solution in D10? In #2353867: [META] Expose Title and other base fields in Manage Display?
So in D10, the title field would be rendered like any other field using the regular field template? So the markup would be something like
<div class="field ..."><h2>...</h2></div>, where the<h2>would be coming from the field formatter? Or is this not fully planned yet?I think there are other use cases where it would be useful to switch the field template independently from the field name and the formatter. Currently this can be done in contrib, e.g. using Display suite field templates. But any such contrib solution will need to incorporate or work around the theme hook suggestion mechanism. E.g. any contrib module that wants to introduce a
field--inline.html.twigwill need to consider the case where "inline" actually matches an existing theme hook suggestion. Currently this could only happen if there is either a field type or an entity type named "inline" (field names are typically prefixed), which seems unlikely. But the current suggestion mechanism does limit the namespace that such contrib modules could use. Perhaps we need to rethink the suggestion mechanism for D10.But I guess we should keep this issue strictly about D9, and discuss anything related to D10 elsewhere.
Comment #109
donquixote commentedSome code review for #103.
Is the '__node' reliable?
I think it will match or fail depending on the field template the theme uses.
It will fail on
"field__{$field_type}"or"field__{$field_name}", but it will match"field","field__{$entity_type}","field__{$entity_type}__{$bundle}","field__{$entity_type}__{$field_name}"and"field__{$entity_type}__{$field_name}__{$bundle}". At least this is what I remember from last time I checked how this mechanism works.We should add
/** @var \Drupal\node\NodeInterface $node */in the line above, to allow static code analysis by the IDE.For my taste, there is too much happening in one line here.
But then I looked at existing places where we do this as an
if (..)condition, they also have this check in one line.However, we can eliminate the parentheses and replace && with ||, this also makes us more consistent with other places in code. And swap the two sides of the ||, like so:
---------
Besides this, I wonder, is preprocess the right place to do this?
Perhaps it is. But for contrib, should we provide ways to control this behavior from the render element? E.g. to allow formatters to set an '#is_inline' flag?
The two distinct settings 'display configurable' and 'enable_base_field_custom_preprocess_skipping' seem awkward to me. Since both are boolean, there are 4 different combinations/scenarios per field. I wonder if each of those 4 are meaningful choices, and whether we have a well-designed "expected behavior" for all of those 4 combos.
This was already introduced in #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI, so there is no point to change it now. But we should at least document what we expect to happen in each of those cases.
Comment #110
donquixote commentedSome observations
With current code and this patch, I found the following places where we are going to check for
'enable_base_field_custom_preprocess_skipping'and->isDisplayConfigurable():This made me wonder: Why don't we have a field template override for taxonomy term name?
I installed D9 with umami, set up a view mode for terms, and found this html in a term view mode:
, instead of using the field.
Proposal
It seems to me that:
$variables['label']should render as inline, either using<span class="field ...">, or no wrappers at all.$variables['elements']['title']should have the regular field wrapper markup with<div class="field ...">.Therefore, could we set the 'is_inline' in
template_preprocess_node()?Like so:
We could then add 'is_inline' to the variables in the 'field' theme hook, so it will be added to the $variables array.
Also, by doing this, we perhaps no longer need the '#is_page_title'.
As a next step, we could move this entire logic from the entity preprocess phase to hook_entity_view_alter(), so it would happen on render element level. We could also allow a setting in the view mode render element, that could be set in contrib, and that would control this behavior per view mode.
I don't know yet if any of these ideas would be problematic for BC.
Comment #111
adamps commentedRe #108:
You could look at #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display" which explains the parts that will be deprecated. All the messy, ugly parts that you are uneasy about are scheduled for removal.
Exactly right.
Yes - you have some interesting ideas however this issue has a very specific purpose.
Comment #112
adamps commented#110 is hard for me to follow.
The problem in this issue is entirely specific to these 3 specific node fields. They are the only ones that have a per-field override that generates inline content in a hardcoded way. Whatever you are seeing for taxonomy terms is not this bug it's something else.
This issue is trying to solve a specific bug with minimal changes to code in as safe as possible way. So the answer to "why don't we" or "we could then add", "As a next step, we could move" is that those things are not required to solve the bug. What's more, almost anything you move from one place to another usually breaks BC in complicated ways.
It took many hours of patient careful study and peer review to find the solution here. If can find a clear problem with it then sure write it down and I will discuss. I'm afraid I can't realistically answer (or even always remember) every one of your ideas in detail as to why it doesn't work. However as quick example where I can see what appears to be a problem: we don't use the node preprocess/template as it is only called when rendering an entire node. It is missed for a single field render perhaps via Ajax, such as quickedit.
Comment #113
adamps commentedRe #109
Well the tests pass! I think what saves us is that the templates we care about are all node specific: field--node-uid.html.twig and so on. Similar code already exists in
rdf_preprocess_field__node__uid. If you still think there is a problem please can you explain precisely how to hit it?Good idea, will do.
So you have applied "De Morgan's laws". I don't believe that there is a universally agreed view that this makes things simpler. In this case, the logic I wrote exactly corresponds to the comment above so I think it's clearer to stay as it is.
The first is an important mechanism that applies to all fields on all entities. The second is a slightly awkward temporary BC mechanism. However I don't want to get drawn into this as I believe that is part of another another issue, not this one.
Comment #114
adamps commentedNew patches fixes:
Comment #116
adamps commentedThe tests failed due to a bug in Olivero #3215220: Field wrappers and customisations not working for node date
Comment #117
jonathanshawComment #118
donquixote commentedYes, I forgot how it is called, too long ago :)
I cannot point to a specific Drupal convention, but I do find that comparable places in code use a negation normal form.
(I just looked this up, I am not trying to prove any authority on the matter)
Here is the result of a search:
There is also a performance argument to be made: evaluating the variable should be faster than doing the method call, so it would make sense to put the variable first.
Comment #119
adamps commentedThat's a very good point - let's be consistent.
Comment #120
jonathanshawComment #121
effulgentsia commented+1 to the approach here. Looks really good.
It looks like the assertions that replaced these removed the CSS classes (e.g.,
.field--name-created) from the selectors. Is that because some of the themes don't include those CSS classes? Do we want to add additional assertions for the themes that do? Otherwise, seems like we might introduce a regression that removes the classes without a test that catches that.One could certainly argue that asserting for these classes isn't really part of the scope of this test, but I don't think we have any other test that does it. Bonus points if we figure out a better test (or create a new one) to put that into.
Comment #122
adamps commentedThanks for the review.
Yes - the two stable ones don't have them.
Yes I was tempted to😃.
Here it is - I added an option whether to check the classes on each theme. I hope that "bonus points" might lead to a commit soon. This issue has been close to commit for about 3 years and it would be great to finish it.
Comment #123
jonathanshawNice
Comment #124
effulgentsia commentedThank you for the test changes. Adding issue credits for reviewers.
Comment #126
effulgentsia commentedPushed to 9.3.x, published the CR, and added a release note snippet to the issue summary (feel free to edit that snippet as needed) for when it's time to make release notes for 9.3.0.
Thank you everyone for all your work and patience on this.
Comment #127
adrian83 commentedCongratulations! Thank you to all.
Comment #128
andypostLooks CR is wrong about
inline_fieldusage in template, it should beis_inlineComment #129
adamps commentedGreat many thanks @effulgentsia. Well spotted @andypost CR now fixed.
The focus for this [META] area now moves to the related issue that is also RTBC: #2941208: Title formatting broken due to flawed EntityViewController->buildTitle.
Comment #130
andypostpolished CR