I've seen an increase in the number of "Theme hook is not in the correct place" issues showing up. The debug for these all look correct so I'm reworking the detection logic to be a little smarter.

#1448722: Theme hook is not in the correct place.
#1141700-13: Theme hook is not in the correct place.
#1443000: Adv CSS/JS Agg - Theme Hook

Comments

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new2.46 KB
mikeytown2’s picture

Re-worked the cdn exception and made the comment more descriptive.

mikeytown2’s picture

Status: Needs review » Fixed

This patch has been committed.

udvranto’s picture

Getting this error with the latest dev:

template_preprocess
template_preprocess_page
faq_preprocess_page
i18nmenu_preprocess_page
i18n_preprocess_page
phptemplate_preprocess_page
ctools_preprocess_page
advagg_processor
labjs_preprocess_page
mikeytown2’s picture

StatusFileSize
new405 bytes

Thanks for the heads up. This patch has been committed.

doublejosh’s picture

Mind pointing out where I can read up on the actual issue being noted by this debug?
Sounds like the problem is not actually present, but would like to understand better. I got it while installing the CDN module; assuming that's the norm.
Thanks.

mikeytown2’s picture

@doublejosh
Example of this check doing the correct thing #1441294: Theme hook is not in the correct place.

doublejosh’s picture

Hey Mike, I'm trying to understand what the actual problem is that the debug looks to avoid.
Presume it's testing to be sure advagg is last (which it is, as noted by you saying the debug looks fine.)

_rules_action_drupal_goto_handler
i18nmenu_node_navigation_links_prepare
context_page_alter
zen_show_blocks_discovery
template_preprocess
template_preprocess_page
context_preprocess_page
context_layouts_preprocess_page
i18nmenu_preprocess_page
i18n_preprocess_page
nodewords_preprocess_page
zen_preprocess
zen_preprocess_page
MYTHEME_preprocess
MYTHEME_preprocess_page
zen_process
ctools_preprocess_page
advagg_processor
mikeytown2’s picture

AdvAgg is making sure its last. As for why its throwing an error for you here is odd... Any way you could debug inside of the advagg_install_theme_registry_location() function for me since I can't repo this on my local box?

mikeytown2’s picture

Status: Fixed » Active

@doublejosh
Any help with debugging this?

doublejosh’s picture

Tossed in a few dsm() for $function within hook_requirements...

Initially $function is set to: advagg_processor
After if (module_exists('cdn') && function_exists('cdn_theme_registry_alter')) { it's set to: ctools_preprocess_page

Within that hook it appears like CDN does not register a preprocess_page function in this list. However cdn/cdn.fallback.inc includes a cdn_preprocess_page() function.

The CDN registry_alter attempts to make it last...

/**
 * Make CDN's page preprocess function run *after* everything else's, so that
 * a theme can't call drupal_get_js() and mess everything up.
 */
function _cdn_fallback_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['page'])) {
    // If CDN's preprocess function is there already, remove it.
    if ($key = array_search('cdn_preprocess_page', $theme_registry['page']['preprocess functions'])) {
      unset($theme_registry['page']['preprocess functions'][$key]);
    }
    // Now tack it on at the end so it runs after everything else.
    $theme_registry['page']['preprocess functions'][] = 'cdn_preprocess_page';
  }
}
mikeytown2’s picture

Is this against the latest dev?
http://drupalcode.org/project/advagg.git?a=search&h=refs%2Fheads%2F6.x-1...

I do have some checks against the CDN module but not both in that form.
http://drupalcode.org/project/advagg.git?a=search&h=refs%2Fheads%2F6.x-1...
(looks like clicking through to the line # is broken)

doublejosh’s picture

Seems to me you actually want CDN to run after advagg. I'd like to serve my aggregated CSS and JS from CDN.
I'll make a patch that doesn't attempt to pop-off the cdn_preprocess_page() function and removes the debug.
Something I'm missing?

doublejosh’s picture

Yeah, that's what I was referring too.

    init_theme();
    $hooks = theme_get_registry();
    // TODO: Make this exception list into a hook.
    $function = array_pop($hooks['page']['preprocess functions']);
    if (module_exists('labjs')) {
      $function = array_pop($hooks['page']['preprocess functions']);
    }
    if (module_exists('headjs')) {
      $function = array_pop($hooks['page']['preprocess functions']);
    }
    if (module_exists('designkit')) {
      $function = array_pop($hooks['page']['preprocess functions']);
    }
    if (module_exists('conditional_styles')) {
      $function = array_pop($hooks['page']['preprocess functions']);
    }
    if ($function != 'advagg_processor') {
      $requirements['advagg_theme'] = array(
        'title'       => $t('Adv CSS/JS Agg - Theme Hook'),
        'severity'    => REQUIREMENT_ERROR,
        'value'       => $t('Theme hook is not in the correct place.'),
        'description' => $t('On the <a href="@performance">performance page</a> clear the cache. If this is still an issue open up a bug on the <a href="http://drupal.org/node/add/project-issue/advagg">advagg issue queue</a> and be sure to include the "Hook Theme Info" output from the Advanced CSS/JS aggregation <a href="@settings">settings page</a>.', array(
          '@performance'  => url('admin/settings/performance'),
          '@settings'     => url('admin/settings/advagg'),
        )),
      );
    }

I'm suggesting you remove the CDN check as that's running after AdvAgg anyhow.
Your check is failing because the CDN preprocess_page isn't there yet and you're stripping out whatever happened to be at the bottom (in my case ctools).

mysql> select name, weight from system where name = 'advagg' OR name = 'cdn';
+--------+--------+
| name   | weight |
+--------+--------+
| advagg |    250 |
| cdn    |  10000 |
+--------+--------+

Maybe you tweaked the weight in your setup?

mikeytown2’s picture

This code block

    // TODO: Make this exception list into a hook.
    $function = array_pop($hooks['page']['preprocess functions']);
    if (module_exists('labjs')) {
      $function = array_pop($hooks['page']['preprocess functions']);
    }
    if (module_exists('headjs')) {
      $function = array_pop($hooks['page']['preprocess functions']);
    }
    if (module_exists('designkit')) {
      $function = array_pop($hooks['page']['preprocess functions']);
    }
    if (module_exists('conditional_styles')) {
      $function = array_pop($hooks['page']['preprocess functions']);
    }

got replaced in #2 which has been committed. The new code looks like this:
http://drupalcode.org/project/advagg.git/blob/7d17df6d84c9fac4cbbceee940...

doublejosh’s picture

Cripes.
I'll update to dev and re-check.

mikeytown2’s picture

Any news on this?

doublejosh’s picture

Got a big pile of requests on my module today. Will be looking at this this week.

mikeytown2’s picture

Status: Active » Fixed

Going to mark this as fixed as I believe it is now.

Status: Fixed » Closed (fixed)

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