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.
The modernizr_preprocess_html() function executes variable_set() on every single page load. This is obviously a performance problem.
Comments
Comment #1
ruplah yes, that ol' function.
That code was inspired by conditional_styles way back when I first started hacking on this module. The key benefit to using
hook_preprocess_html()
is that it can look inside the .info file of the active theme, something that is not always possible within hooks.I can't find a
hook_registry_rebuild()
equivalent. Am I just missing it? Zen, for instance, just drops the rebuild code into template.php outside any function declaration. That seems like it would be worse than what I have now.Either way, I agree that it should be moved into a function that is not invoked every page load.
Comment #2
iamcarrico CreditAttribution: iamcarrico commentedDiscussed with @rupl the possibility of just using &drupal_static() instead, it will provided the needed functionality.
Comment #3
iamcarrico CreditAttribution: iamcarrico commentedWithin a bug fix I made, I also fixed this in #1936728: Warning: Invalid argument supplied for foreach() in modernizr_preprocess_html() (line 262 of modernizr.module). Marking as a duplicate for now...
Comment #4
ruplConfirmed, this is fixed in dev due to ChinggizKhan's other patches. We're using drupal_static() on these types of functions and there aren't any unnecessary writes to the DB.
I'm marking this fixed instead of dupe because this issue itself is unique. Thanks for bringing this up, Damien!
Comment #4.0
ruplIt doesn't happen at the *end* of the page load, but rather at the end of the function call *on* every page load.