The modernizr_preprocess_html() function executes variable_set() on every single page load. This is obviously a performance problem.

Comments

rupl’s picture

ah 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.

iamcarrico’s picture

Discussed with @rupl the possibility of just using &drupal_static() instead, it will provided the needed functionality.

iamcarrico’s picture

Status: Active » Closed (duplicate)

Within 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...

rupl’s picture

Status: Closed (duplicate) » Closed (fixed)

Confirmed, 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!

rupl’s picture

Issue summary: View changes

It doesn't happen at the *end* of the page load, but rather at the end of the function call *on* every page load.