With the recent commits that moved the includes to hook_init(), this opened up a much larger issue: sites that use CCK (which seems like just about everyone) can *no* longer use aggressive caching, because that stops hook_init().
I would like to see this change reverted, if possible, it's a major drawback.
However, the reason for this commit was to speed up includes. Perhaps this could be done using the old style but using a static variable check to see if the files have been included or not so it doesn't have to duplicate that call (like it was doing before).
How does that sound?
Comments
Comment #1
eaton commentedThis is extremely important: on high traffic sites, the boost from including files in hook_init() is far outweighed by the loss of agressive caching.
Dopry's suggesting in http://drupal.org/node/108506 to move content_admin functions to a separate module is a better alternative. For now, can the http://cvs.drupal.org/viewcvs/drupal/contributions/modules/cck/content_a... commit be rolled back?
Comment #2
yched commentedEr, my bad, I overlooked that.
There were three includes loaded in global scope before :
content_views.inc
pathauto.inc
content_crud.inc
I guess having the first two in hook_init is not problematic, or is it too ?
More generally I thought the general rule for modules was to avoid anything in global scope.
Did I invent that, or is this no longer true due to aggressive caching, or is there a third way ?
Comment #3
eaton commentedIt is, unfortunately -- in a nutshell, any module that implements hook_init() breaks aggressive caching. I can help dig into alternatives for performance, but the high-performance sites that are most sensitive to performance issues will be hit harder by the loss of aggressive caching... we're seeing that on two large-scale sites right now.
Comment #4
eaton commentedPerhaps it would make sense to put the inclusion code inside the wrapper functions. For example, content_pathauto() could issue a require_once() inside the function itself, keeping the main code clean.
hook_menu(), when $may_cache is FALSE, is another option.
Comment #5
yched commentedWell, I'd like to avoid hook_menu for content_views.inc because it has to be loaded before views_menu executes, and thus we embark in {system}.weight niceness... As a matter of fact I stole this hook_init optimization code from OG - see http://drupal.org/node/102526#comment-174676. OG might therefore be affected as well ?
And content_pathauto.inc in hook _menu does not seem recommended either : http://drupal.org/node/60526
And, sorry for being blunt, but I don't really understand why implementing hook_init would _break_ aggressive caching.
Looking at the code, it seems aggressive caching (as opposed to normal) "simply" does not call init_hooks.
So a warning is issued on admin/settings/performance stating that the modules implementing hook_init _might_ not function properly, and not the other way around : it's not aggressive caching that will break, if I get this right.
You're not telling me that hook_init has become a forbidden hook, right ? :-)
Meaning statistics.module for instance _will_ lose some functionality, but content.module should not be affected. With the current code, we're not including the files even with normal caching (
if (function_exists('drupal_set_content')) {part). To me, content.module is behaving the same for normal or aggressive caching.Comment #6
mfer commentedI did a little basic testing on functionality and aggressive caching seemed to work with CCK. I haven't dug into all the ins and outs but viewing content worked fine and everything displayed.
Comment #7
eaton commentedI did some additional investigation, and I'd like to offer an apology -- you're right. CCK does work fine with aggressive caching, as it doesn't *have* to execute when caching is in effect. Thus, the user just receives unnecessary warnings when turning on aggressive caching. They can ignore them in this case, whereas they can't with something like statistics.module. :-)
Comment #8
karens commentedWhat warnings will they see? Let's just document that so they don't worry when they see them.
Comment #9
eaton commentedOn the aggressive caching page, it says, "The following modules are incompatible with aggressive caching, and will not work properly: content." Devel is another such module. It basically looks for anything that implements hook_init().
Comment #10
yched commentedWe should remove the need for hook_init(), I opened a task for this, so closing this one
Comment #11
karens commentedJust to make it easier to find, the followup issue is at http://drupal.org/node/127106.
Comment #12
yched commentedEr, right. Thanks Karen, I got lazy on this one :-)
Comment #13
killes@www.drop.org commented