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.
On sites with a lot of translations locale() is quite slow, as for every call drupal_static is called.
Comment | File | Size | Author |
---|---|---|---|
#7 | 1387766-fast.patch | 742 bytes | dawehner |
#5 | standard.png | 37.93 KB | Kars-T |
#5 | patch.png | 54.03 KB | Kars-T |
#1 | 1387766-fast.patch | 762 bytes | dawehner |
#1 | xhprof.png | 43.36 KB | dawehner |
Comments
Comment #1
dawehnerHere is a xhprof screenshot + a patch
Comment #2
dawehnerAdd tag
Comment #3
droplet CreditAttribution: droplet commentedmore discuss: #1135950: Remove static caching in t()
Comment #4
dawehnerThe other issue is about the static in t() this one about the one in locale(), this seems to be fundamental different places
Comment #5
Kars-T CreditAttribution: Kars-T commentedThis patch is an exact copy of what is done in user_access()
So as this is in core I'd say code wise it is good.
On the performance side I did test this on our biggest site and added some xhprof screenshots as well. It's over 2.500 calls to drupal_static() we can cut away with this in my environment.
Standard Drupal Core
Patched Drupal Core
Comment #6
catchLooks good, thanks for the xhprof screenshots :)
Committed/pushed to 8.x.
Moving for backport just in case.
Comment #7
dawehnerHere is a patch for 7.x
Comment #9
dawehnerUpdate status
Comment #10
Kars-T CreditAttribution: Kars-T commentedVery same patch as in D8 except the file path. So I set this again to RTBC.
Comment #11
webchickFancy pants. :)
Committed and pushed to 7.x. Thanks!
Comment #12
dawehnerAwesome!
Thanks for committing the patch!