$_advagg['ctools_patched'] only set when ctools/includes/ajax.inc is loaded, not on every page. advagg_theme_registry_alter() is run only once, then the theme registry is cached. It happens that when advagg_theme_registry_alter() runs, ajax.inc is not loaded, thus ctools_ajax_page_preprocess is not removed from the theme registry. That causes duplicate content in the closure.

Also sometimes the 'css' array is lost. I'm debugging, but haven't got there yet. I have ctools patched. Screenshot attached. 'css' is present only after cache is clear, and disappears after that.

http://dev.jcisio.com/snap/20120723233952.png
http://dev.jcisio.com/snap/20120723234119.png

CommentFileSizeAuthor
#5 advagg-1698210-4-fix-ctools.patch535 bytesmikeytown2
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcisio’s picture

In fact, ctools_ajax_page_preprocess is not a hook implementation and is never in the 'preprocess functions' array. It is called indirectly in ctools_preprocess_page(). The problem comes from elsewhere.

jcisio’s picture

I continue the debugging: the array of loaded CSS is added using advagg_advagg_css_pre_alter (hook implementation). This hook is called only in advagg_process_css(). This function is called in:
- advagg_get_js_css_get_array(): this is a helper function, is not directly used in AdvAgg but helps other modules like QuickTabs.
- advagg_processor(): a page preprocess function. However at this level, if the full cache is enabled (it is by default), there is a big chance that the advagg_process_css() is not called.

So, a workaround is to disable the advagg full cache setting. The fix would be to save also the $css_files array in cache.

I didn't dig further to see why there is no similar problem with the JS.

rjbrown99’s picture

+1, this is a problem.

Easy fix as long as you don't mind including ctools ajax in hook_init, just add this above that stanza:

ctools_include('ajax');

... where the final looks like so:

  ctools_include('ajax');
  // Disable ctools_ajax_page_preprocess() if this functionality is available.
  if (variable_get('advagg_enabled', ADVAGG_ENABLED) && function_exists('ctools_ajax_run_page_preprocess')) {
    ctools_ajax_run_page_preprocess(FALSE);
    $_advagg['ctools_patched'] = TRUE;
  }

  • mikeytown2 committed 3a67a04 on 6.x-1.x authored by rjbrown99
    Issue #1698210 by rjbrown99: ctools_ajax_page_preprocess is not always...
mikeytown2’s picture

Issue summary: View changes
Status: Active » Fixed
FileSize
535 bytes

ctools_include('ajax'); has been added to advagg_init.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.