After Redis was enabled, noticed that some pages were returning blank on first load. The nginx logs noted this error:

[error] FastCGI sent in stderr: "PHP message: PHP Fatal error:  Unsupported operand types in /sites/all/modules/panelizer/plugins/task_handlers/panelizer_node.inc on line 311" while reading response header from upstream

Did some investigation, and saw the code around line 311 is running twice when cache is cleared, and logged this result in watchdog:

panelizer  $panel_body_css = Array ( )
panelizer  $info[classes_array] = Array ( [0] => node-unpublished )
panelizer  $panel_body_css =
panelizer  $info[classes_array] = Array ( [0] => node-unpublished )	

On the second execution $panel_body_css is not an array, which throws the error message for line 311.

The root cause of this is how Panels handles the same $panel_body_css variable. In both panels_preprocess_html and panels_panel_context_render, the call is defined as follows:

$panel_body_css = &drupal_static('panel_body_css');

The problem is Panels has not defined a default array() if panel_body_css is empty, while Panelizer depends on it.

Putting an is_array around line 311 in panelizer_node.inc solves the problem, but maybe you feel the patch should be on Panels to add a default array()? I'm not sure this variable *should* be forced to be an array, or is more of an specific need set by Panelizer.

Also I'm not entirely sure why line 311 even exists... it merges an empty value for the key body_classes_to_add into $panel_body_css, only to have it completely reset on the very next line.

Patch is attached for review, thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ron_s created an issue. See original summary.

ron_s’s picture

Issue summary: View changes
DamienMcKenna’s picture

Project: Panelizer » Panels
Status: Needs review » Needs work

I completely agree with your suggestion that this should be in Panels and that "panel_body_css" should be an array by default, instead of NULL.

ron_s’s picture

Status: Needs work » Needs review
FileSize
1.69 KB

Ok, here's a patch that sets default values to array() in Panels. See attached.

ron_s’s picture

This patch still works in the latest 7.x-3.10 release. Please review, thanks.

joelpittet’s picture

Status: Needs review » Fixed

Thanks again @ron_s, I've committed this to the dev branch.

  • joelpittet committed 635ccd7 on 7.x-3.x authored by ron_s
    Issue #2985814 by ron_s: Unsupported operand types in panelizer_node.inc...

Status: Fixed » Closed (fixed)

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

joelpittet’s picture