I've run into a strange issue where page manager pages don't have the needed advagg_font JavaScript attached.

I'm no expert by any means, but here's where I've narrowed the problem down to.

/**
 * Implements hook_page_build().
 */
function advagg_font_page_build(&$page) {
  // The $page variable is not an array; or the content key does not exist.
  if (!is_array($page) || !isset($page['content'])) {
    return;
  }

It seems even though $page['content'] exists later, it doesn't exist yet. No JavaScript gets attached so no font fun.

I see two possible solutions here:

1. Changing advagg_font_page_build() to advagg_font_page_alter() causes it to fire later in the process and appears to work ($page['content'] exists at that point), but I don't know enough to say if that's a viable solution.

2. Removing the check for $page['content'] also fixes the problem of course. Since nothing is read from $page and only appending to it, maybe that would work?

I'm not sure what direction would be best. If one of these seems feasible I'd be happy to roll a patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ZHawkins created an issue. See original summary.

mikeytown2’s picture

I need to check for $page['content'] otherwise it can get wiped out later on by something doing $page['content'] = array(...);

Looking at drupal_render_page() and using the alter hook is the simplest thing to do. The other alternative to to change the execution order of the hook (move advagg to the bottom) by using hook_module_implements_alter().

ZHawkins’s picture

Is there an advantage to using one over the other? If not I'll go ahead and roll the alter hook into a patch.

mikeytown2’s picture

Here's what I was thinking, does this work for you?

mikeytown2’s picture

Status: Needs review » Fixed
ZHawkins’s picture

Oh fantastic. Thanks so much!

Status: Fixed » Closed (fixed)

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