Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If another preprocessor or processor has already rendered the $page variable AdvAgg will clobber $page_top, $page_bottom and $page resulting in an empty page.
The problematic code is:
if (isset($variables['page']['page_top'])) {
$variables['page_top'] = drupal_render($variables['page']['page_top']);
}
elseif (!isset($variables['page_top'])) {
$variables['page_top'] = '';
}
if (isset($variables['page']['page_bottom'])) {
$variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
}
elseif (!isset($variables['page_bottom'])) {
$variables['page_bottom'] = '';
}
// Place the rendered HTML for the page body into a top level variable.
if (isset($variables['page']['#children'])) {
$variables['page'] = $variables['page']['#children'];
}
The problem is if $variables['page'] is a string 'page_top' gets cast to the integer 1, isset() returns true and we end up calling drupal_render() on the second character of the string and set $variables['page_top'] to the return value.
We should probably check that $variables['page'] is indeed an array in these if statements to fix the problem. I'll attach a patch in the comments.
Comment | File | Size | Author |
---|---|---|---|
#2 | advagg_check_if_page_variable_is_an_array-2549597-1.patch | 1.1 KB | Dean Reilly |
Comments
Comment #2
Dean Reilly CreditAttribution: Dean Reilly commentedComment #3
DamienMcKennaLooks entirely reasonable.
Comment #5
mikeytown2 CreditAttribution: mikeytown2 commentedThanks for the patch! Also thanks for testing out the patch! It's been committed.