Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There's a typo in the inline documentation within \Drupal\Core\Render\Renderer::doRender
$supported_keys = [
'#lazy_builder',
'#cache',
'#create_placeholder',
// These keys are not actually supported, but they are added automatically
// by the Renderer, so we don't crash on them; them being missing when
// their #lazy_builder callback is invoked won't surprise the developer.
'#weight',
'#printed'
];
Proposed resolution
This should be re-worded to fix the "... them; them ..." portion. And also needs to be re-wrapped as it exceeds 80 characters.
Remaining tasks
Update the inline comment and provide a patch.
Comment | File | Size | Author |
---|---|---|---|
#22 | 2853684-22.patch | 898 bytes | tameeshb |
#22 | interdiff-19-22.txt | 597 bytes | tameeshb |
#19 | interdiff-16-18.txt | 654 bytes | tameeshb |
#19 | 2853684-18.patch | 897 bytes | tameeshb |
#16 | interdiff-2853684-15-16.txt | 524 bytes | krknth |
Comments
Comment #2
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedDoes this text look fine? Please review.
Comment #3
leolandotan CreditAttribution: leolandotan as a volunteer and at Promet Source commentedHi @tameeshb, I found some minor coding standard issues:
Please add a space before the next sentence.
Please transfer this to the previous line. I think this can still be inside the 80 character length limit.
Thanks!
Comment #4
leolandotan CreditAttribution: leolandotan as a volunteer and at Promet Source commentedComment #5
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedMade changes from #3.
Comment #6
chiranjeeb2410 CreditAttribution: chiranjeeb2410 commentedMade required changes
Comment #7
tameeshb CreditAttribution: tameeshb at Google Summer of Code commented@chiranjeeb2410 ? Patch with changes was already uploaded in #5.
Also, your patch violates coding standards on line one of change.
It is recommended to upload interdiffs with patches.
Comment #8
wturrell CreditAttribution: wturrell as a volunteer commentedComma added to closing array item (as per code style).
I think it'd make it clearer if we clarified whether it's the keys above or below the comment block that are unsupported (and I'm not very familiar with this code yet, so not 100% sure which).
Comment #9
chiranjeeb2410 CreditAttribution: chiranjeeb2410 commented@tameeshb,
Will be sure on that part. Thanks, anyways.
Comment #10
eojthebraveThe comments are in reference to the keys below the inline comment. Specifically #weight, and #printed. Personally I'm not convinced that we need to clarify that, inline comments are almost always in reference to the thing below the comment and not above it. However, if you feel like this is a major point of confusion in this case then we can totally try and clarify that.
Comment #11
wturrell CreditAttribution: wturrell as a volunteer commented@eojthebrave - As it was such a trivial change I've done it anyway - but yes, hopefully it will be obvious to most people.
The patch looks ready to RTBC to me:
- reads better than it did before
- it's comments only, so no regressions, no string, API changes, browser testing or anything
- code style, line length fine, no CodeSniffer errors, we've added the comma for final array element.
Comment #12
chiranjeeb2410 CreditAttribution: chiranjeeb2410 commented@wturell,
Changes are good to go with. Code style is fine. Inline comment issue wasn't that big a deal though. Anyways, patch applies cleanly.
Changing it to RTBC.
Comment #13
tameeshb CreditAttribution: tameeshb at Google Summer of Code commented#11 : +1
Comment #14
xjmThanks everyone for cleaning this up!
I think this is definitely an improvement! However, I think it's also missing some information that is there (but not very clear) in the original text, which is "so we don't crash them". I think that might be either saying that the renderer adds them to ensure that nothing breaks when the #lazy_builder callback is invoked.
Also let's try to get rid of the bit about surprising the developer as that's also a bit confusing.
Maybe we should look at who originally added this documentation (Fabianx maybe?) to tease out what is meant here. Or, better, let's just have a subsystem maintainer review this and help with this. I'll ping Wim for help figuring out what this means.
Technically, this is coding standards fix is out of scope, and should instead be added in an issue to add missing trailing commas to arrays across core and then enable the coder rule that checks it. See: https://www.drupal.org/core/scope#coding-standards
Comment #15
chiranjeeb2410 CreditAttribution: chiranjeeb2410 commented@xjm,
Patch uploaded with minor changes mentioned in 1. Also, +1 on the second suggestion,
regarding the coding standards fix.
Comment #16
krknth CreditAttribution: krknth as a volunteer and at Valuebound commented@chiranjeeb2410 removed coding standard as per @xjm suggestion & re created patch. And also created issue for coding standard
#2855608: [Coding standard] Trailing comma - core/lib/Drupal/Core/Render/Renderer.php
Attached patch, interdiff files
Comment #17
Wim LeersThis is correct. Thanks for fixing the language. But I have a suggestion to make it slightly clearer ("crash" is kind of strange to read in Drupal code).
s/This prevents … invoked./Pretending they are supported allows us to avoid throwing an exception 100% of the time./
Comment #18
xjm#2572613: Fix 'Drupal.Array.Array.CommaLastItem' coding standard is the existing standards issue for trailing commas, so updated the split-off issue to that instead. Thanks!
Comment #19
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedEdits from #17 on patch at #16
Comment #20
tameeshb CreditAttribution: tameeshb at Google Summer of Code commented*2853684-19.patch
and
*interdiff-16-19.txt
Comment #21
Wim LeersMissing space after period.
Comment #22
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedSpace added on #19
Comment #23
Wim LeersThanks!
Comment #24
Wim LeersComment #27
xjmAh, I get it now, thanks!
The word "pretending" was still a little weird for the tone, so I made a very small rewording on commit:
Committed to 8.4.x and cherry-picked to 8.3.x. Thanks!
Comment #28
Wim LeersSorry for my confusing language :(