Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
field system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
2 Jan 2010 at 12:35 UTC
Updated:
29 Jul 2014 at 18:35 UTC
Which means drupal_static() gets called about 130 additional times on a standard front page with ten nodes. Attached profiling output.
| Comment | File | Size | Author |
|---|---|---|---|
| drupal_static_fields.patch | 970 bytes | catch | |
| drupal_static_before.png | 104.6 KB | catch | |
| drupal_static_after.png | 57.37 KB | catch |
Comments
Comment #1
yched commentedLooks good to me. Should we add a comment on those 'advanced drupal_static() pattern', or are they considered standard already ?
Comment #2
catchThere's a big phpdoc hunk in drupal_static() which went in with the original patch, the hope is that people look there when they see the weirdness.
Comment #3
effulgentsia commentedJust my $0.02, but I would really like to see #619666: Make performance-critical usage of drupal_static() grokkable land first, and this be re-rolled with that change. The other uses of the advanced pattern currently in HEAD do not pass a default to drupal_static(), and one reason I rolled the patch that introduced the advanced pattern that way is because that middle line is so long and obscure that I thought it would be better DX to have it always be identical everywhere it's used. However, I think the cleanup patch in that issue makes the line sufficiently more grokkable that having a use-case like this that passes a default to drupal_static() is ok (with only one use of __FUNCTION__ in that line of code, it's recognizable what the parameter after it means).
Also, I'd encourage adding the 1-line comment to this patch (copy it from other uses). But I also wonder if we want to change that comment line to something else, maybe something that includes an
@see drupal_static()directive. That's not for this issue, but the fact that this patch was rolled without including that 1-line comment makes me realize that the comment isn't sufficiently clear and/or useful.Comment #4
catchI've just marked the other one RTBC, postponing this.
Comment #5
effulgentsia commentedThe other one landed. Please re-roll and add comment.
Comment #6
mgifforddrupal_static_fields.patch queued for re-testing.
Comment #8
swentel commentedStill needed for D8 ?
Comment #9
swentel commentedHmm apparently not, looks like this has been handled in separate commits, for both D8 and D7.