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.
Hi
the call to t() takes away loads of performance from our site. I asked dereine in IRC and he said that to use t() here doesn't make sense. So here is a patch to remove it.
Comment | File | Size | Author |
---|---|---|---|
remove_t_from_set_option_default.patch | 581 bytes | Kars-T | |
|
Comments
Comment #1
dawehneradd tagj
Comment #2
drupalexio CreditAttribution: drupalexio commentedSimple and correct. It works.
Comment #3
dawehnerJust some discussion in irc:
Comment #4
dawehnerSo the roadmap is actually
* Test unpack_options and set_options_defaults
* Refactor unpack_options to support setting the default options
Comment #5
dawehnerRelated issue #1388078: Optimize unpack_options by not calling init_localization all the time.
Comment #6
dawehnerAnother related issue #1388092: Test set_options_defaults and unpack_options
Comment #7
dawehnerIf someone is using views in another language then english, the expectation might be to have all configuration translated on the initial adding, which would be removed with this patch, so i'm not sure whether it still makes sense to do it.
Comment #8
nmalinoski CreditAttribution: nmalinoski commentedThis is still a problem, and it's causing a mess for my team and me. The t() call on line 90 is causing double translation in many cases for us, which leads to tons of bogus strings in the strings table (i.e. Chinese translation text being inserted as English source text.).
There were additional double translation issues, but those were resolved by updating to 7.x-3.13+28-dev; removing this t() call--actually, dumping the entire elseif block (lines 89:91) would be fine--fixes the last of those double translation issues for us.
Comment #9
joelpittet@dawehner, considering #8, maybe best to remove this and deal with the unpacking in a separate issue?
The other option is to static cache existing translations because most of them are like 'more', but from translation point of view this should be done at the time of creation with t() on the string so that the potx and other tools can statically analyze them.
Comment #10
DamienMcKennaSo.. is this "RTBC" or "won't fix"? I'm confused.
Comment #11
joelpittetI think it may need @dawehner to make that call but rtbc from my point of view. t($var) is not useful for the extraction of strings and discouraged.
Comment #12
joseph.olstadWe've applied this change. Thanks
Comment #13
joseph.olstadWe used this patch and found an issue with it.
when using this patch, our "Show more" pager that we use with views infinite scroll failed to translate to our other language.
Do not use this patch if you plan on supporting more than one language.
backing off the patch restored our pager label translation.
Comment #14
joseph.olstadGoing to mark this won't fix:
Please consider this instead:
#2760405: Reduce the calls to the same t() in views_fetch_fields()
Comment #15
joseph.olstadFor improved views performance, use these instead.
#2760405: Reduce the calls to the same t() in views_fetch_fields()
#2653214: Replace views_include() with include_once
#2653266: Avoid excess t() calls in field_views_field_default_views_data()
#2760419: get_option() micro optimization
Comment #16
joelpittetThanks for listing all my performance issues:)
Comment #17
joseph.olstad@joelpittit , your performance fixes are excellent, really appreciate the profiling screenshots too. I'm a few months away from setting up xhprof myself, got some other things brewing first but xhprof is definately on my TODO list. In the middle of building a super infrastructure for myself, openvz , redundancy , PHP 7 , new servers, rsynced and offsite warm spare, all disks raid1 , spent about 5000$ so far.
Comment #18
joelpittetThat sounds like it's going to be screaming fast!
Most of the xhprof were done with drupalvm. Nicely installs it for you(just remember to turn off xdebug because it can change the results). It can be a pain to setup, may switch to local tideways soon(also on Drupalvm)