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
The _theme() function was removed in #2346937: Implement a Renderer service; reduces drupal_render / _theme service container calls but there are still over 50 references to it in core documentation and 1 in an exception message.
Regular expression used to find the occurrences:
[^a-z]_theme\(
Proposed resolution
Figure out what we should replace this with.
- In some cases we will want to point to a Twig template or preprocess function like in #2226863: Update stale references to theme functions that have been converted to Twig.
- In other cases we will want to point to the Renderer service (or a specific method on the class).
Remaining tasks
- Come up with a plan and write it up in the issue (novice)
- Write patch (novice)
- Review patch to check it fixes the issue, the change is properly documented and for coding standards. (novice)
- Keep issue summary up to date (novice)
Beta evaluation: This is just API docs and code comments (documentation), so it is an unfrozen, prioritized change and allowed during beta.
User interface changes
n/a
API changes
n/a
Comment | File | Size | Author |
---|---|---|---|
#39 | documentation_refers_to-2388247-39.patch | 21.06 KB | snehi |
#39 | interdiff-2388247-36-38.txt | 1.66 KB | snehi |
#36 | interdiff-2388247-28-36.txt | 3.38 KB | pguillard |
#36 | documentation_refers_to-2388247-36.patch | 20.88 KB | pguillard |
#29 | documentation_refers_to-2388247-28.patch | 20.88 KB | sriharsha.uppuluri |
Comments
Comment #1
star-szrActually this seems major.
Comment #2
star-szrComment #3
andypostCurrent state is
Comment #4
jhodgdonThanks for that! We definitely need to fix these, especially the ones that say "For more details, see _theme()" and things like that.
The ones that say things like ... for testing _theme('foo')... we could probably change to saying ... for testing the 'foo' theme hook...
Comment #5
catchGood change to make during RC, moving to task though.
Comment #6
jhodgdonEither way. It seems to me that it's a bug that we have docs referring to a function that doesn't exist, but it's definitely a task to fix them.
Comment #7
catchIf there's any useful distinction between bug and task, it's that 'bug' describes code executing incorrectly in some way.
Tasks can definitely be for things that are wrong, as well as things that could be better.
Comment #8
jhodgdonAre you saying that no issue in the documentation component should be a bug? Incorrect documentation has always been a bug in the past. https://www.drupal.org/node/314328 just says "Bug is for errors".
Comment #9
catchI think we need to distinguish more between 'really bad code' and 'really bad user-facing error'. Right now we have 460 issues in the major bug queue against 8.x, and it can be hard to pick out the should-have-been-critical like #2172843: Remove ability to update entity bundle machine names from that long list.
Things like removing usage of deprecated functions are also tasks - but in terms of overall project health they're major because they do actually affect developer experience in a big way.
Comment #10
jhodgdonAh sorry, I didn't notice this was marked Major. I would think it's an ordinary Normal documentation bug, and actually not any higher priority than other docs bugs to fix, really.
Comment #11
joelpittetHere's my take. May not be all correct conversions but I think they are. Feel free to correct me. I tried using other examples from core depending on the context it was being used.
Comment #12
jhodgdonThis looks mostly great! I have a few mostly minor suggestions:
So in D8 we would actually tend to use #type => 'pager' not #theme => 'pager' to get a pager into a render array. So I'm wondering if rather than referring to pager.html.twig, we should refer to the pager element class instead?
So this is telling people where to look for more documentation.
I doubt that there is documentation in the services.yml file for the 'theme.manager' service... The documentation that used to be in theme() in D7 that is being referred to here is the list of what all the processing and preprocessing functions are for a given theme hook.
This is now in
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api....
which you can reference by saying:
@link themeable Theme system overview topic @endlink
Same here.
Typo: needs space after the .
See comment above about the theme.manager service.
see above, although in a // comment we probably don't want @link so you could probably say something like
See the @defgroup themeable topic
or something like that.
see above
Um. Doesn't this message still need to be wrapped in t()?
This line existed before this patch, but it doesn't make any sense?
"if all modules" what?
I don't think the sentence starting with "The title attribute" is actually part of this bullet?
Comment #13
joelpittet@jhodgdon thank you very much for the review. I wasn't sure about some of those. I'll work on this with someone at badcamp in a couple of days.
Regarding #12.8 I removed the t() from the Exception because I was under the impression we shouldn't be putting t() in to Exceptions. I just confirmed with @alexpott on IRC because we were discussing this a bit in Barcelona.
Comment #14
jhodgdonOh really? They are shown to the user, in many cases... we're not translating the exception messages? Has that been written down somewhere?
Comment #15
joelpittetOh yeah it is written over here: https://www.drupal.org/node/608166
And in progress here: https://www.drupal.org/node/2055851
Comment #16
xjmAs a docs bugfix, this one doesn't need any special committer signoff, so moving to the new "rc eligible" tag. (Not that it makes much difference in practice, but I think it helps contributors to understand which to use for what.)
Comment #17
jhodgdonIt's not quite all API documentation comments (there is one Exception message included), so I'm not sure "rc eligible" is right.
Comment #18
joelpittet@jhodgdon I can leave that Exception exception _theme() reference out of this if you feel uncomfortable committing that. Just move it to a follow-up or the progress issue I mentioned in #15
Edit: it really is exceptional;)
Comment #19
jhodgdonYes, we should probably move that to a separate issue, and then this would be all documentation and all rc eligible for sure.
Comment #20
pguillard CreditAttribution: pguillard commentedI tried to addres most of the points mentioned by @jhodgdon at #12 except 1st point
@joelpittet : Hope you don't take it as an offense, since you said you will follow on your work in next badcamp.
Comments :
#12.1.: I have no idea
#12.9.: At least this truncated comment comes from theme.inc from d7 !
This as been introduced there https://www.drupal.org/node/1011614#comment-4914268 and committed on 29/10/2011 !
Have no idea what it means, I suggest "This is only allowed if the request method is GET"
#17 : I removed the Exception message part to be "rc eligible"
Comment #21
mondrakeFor the pager part, there is also #2530296: Fix up docs in core/includes/pager.inc looking into that. Can we leave the changes to there, or take the piece below (which I understand @jhodgdon agrees upon) from there?
Comment #22
catchI think we can leave the exception message change in - probably we should make exception messages rc eligible too.
Comment #23
jhodgdonLooking pretty good! Thanks!
So, a bit more to do on this one:
@link ... @endlink all needs to stay on the same line. This line can go over 80 characters if necessary, but if that is happening, move @link to the start of the next line so the @link ... @endlink is the only thing on the line.
same here
Um. I think the detailed docs on preprocess functions are actually on the "themeable" topic, right? They most certainly are not on the "theme.manager" service.
So this would need to say:
See the @link themeable [link text] @endlink topic for detailed documentation.
I think maybe a comma before the last "and" here would make this sentence easier to parse?
needs "the" before "theme implementation"
Can this comment be rewrapped to nearer 80 character lines please?
So... I cannot see that $persistable is used or set anywhere in this class or in the one class that uses it, which is
\Drupal\Core\Theme\Registry
Probably this whole doc block and the variable it documents should just be removed. As far as I can see it is dead.
Then we don't have to worry about what this cryptic previous documentation means ;)
extra space end of line
This line needs to be wrapped to 80 characters, as it was in the original before this patch. Really the original lines should just stay as they were.
This line is too long...
but we don't want to wrap it either since it is the first line docs for a function.
How about:
Test theme function for 'theme_test....'.
(don't put in ... put in the actual name of this theme hook).
Comment #24
joelpittet@pguillard no offense at all, thank you very much for helping this! I'm working on lots of issues and welcome any help I can get as most of us do. Please if you have time, continue fixing the notes from @jhodgdon and others.
Comment #25
pguillard CreditAttribution: pguillard commentedApplied suggestions from @jhodgdon #23.
I guess this is it.
Comment #26
jhodgdonGetting closer... Still some things to address:
@link ... @endlink all needs to be on the same line.
So start the @link on the next line.
Same here.
Um. You took me a bit too literally. You need to actually provide some link text here. ;)
The topic is called:
Theme system overview
This line exceeds 80 characters. Rewrap.
These were not changed in parallel ways, so they are kind of inconsistent.
And I guess they are both a bit inaccurate...
Let's change both of them to say:
Theme function for hook [name of the theme hook].
The theme hook names are:
theme_test_foo
theme_test_function_template_override
Comment #27
snehi CreditAttribution: snehi as a volunteer and at Publicis Sapient for Publicis Sapient commentedUnable to apply patch. Need reroll.
Here is the output of my git apply command.
Comment #28
mondrakeThe pager documentation has already been fixed in #2530296: Fix up docs in core/includes/pager.inc, please remove any change to pager.inc as per #23.1
Comment #29
sriharsha.uppuluri CreditAttribution: sriharsha.uppuluri at Azri Solutions commentedRe-rolled the patch. Not worked on comment #26.
Comment #30
mondrake@sriharsha.uppuluri do not forget to set status to 'Needs review' after you upload a patch, so that it can get processed by the testbots and reviewers get to know that there is something to look at :)
Comment #34
sriharsha.uppuluri CreditAttribution: sriharsha.uppuluri at Azri Solutions commented@mondrake Yes, i know that but i didn't do the changes what mentioned in #26 that's why i haven't put it to needs review.
Comment #35
jhodgdonSetting back to Needs Work then, which was correct.
Comment #36
pguillard CreditAttribution: pguillard commentedHad a lumbago... and finally applied suggestions from @jhodgdon at #26 !
Comment #37
jhodgdonThanks for the patch! Sorry for delay in review -- I've been on vacation.
So this looks pretty good! A few minor things to fix:
Probably could use a "the" at the end of the first line here.
And same here.
Why are we removing this? I see in the __construct() for this class, it sets this variable, and it is used in the resolveCacheMiss method. Please instead fix the _theme() mention here.
Comment #38
snehi CreditAttribution: snehi as a volunteer and at Publicis Sapient for Publicis Sapient commentedComment #39
snehi CreditAttribution: snehi as a volunteer commentedDone with changes. Please review.
Comment #40
joelpittetLooks like the feedback was addressed from #37 thank you @snehi
Comment #44
jhodgdonAgreed with RTBC. This is changing one line of non-docs code so moving into base component and leaving for someone else to commit, just in case.
Comment #45
catchCommitted/pushed to 8.1.x and cherry-picked to 8.0.x. Thanks!