After adding #2484843: Allow widgets to control how their "example" is rendered on the "Add content" dialog (including using a static image rather than rendering), previewing a Fieldable Panels Panes widget causes PHP notices. It affects both individual reusable content items, and FPP-based CTools content type plugins.

For a reusable item, the errors are:

Notice: Undefined property: stdClass::$subtype in template_preprocess_panels_pane() (line 1511 of /panels/panels.module).
Notice: Undefined property: stdClass::$type in template_preprocess_panels_pane() (line 1534 of /panels/panels.module).
Notice: Undefined property: stdClass::$type in template_preprocess_panels_pane() (line 1535 of /panels/panels.module).
Notice: Undefined property: stdClass::$subtype in template_preprocess_panels_pane() (line 1535 of /panels/panels.module).
Notice: Undefined property: stdClass::$type in template_preprocess_panels_pane() (line 1510 of /panels/panels.module).

For a CTools content type plugin, there are two more errors:

Notice: Undefined property: stdClass::$fpid in PanelsPaneController->buildContent() (line 307 of /fieldable_panels_panes/includes/PanelsPaneController.class.php).
Notice: Undefined property: stdClass::$fpid in PanelsPaneController->buildContent() (line 308 of /fieldable_panels_panes/includes/PanelsPaneController.class.php).

To reproduce:

  1. Download and install the latest Panopoly release including demo content.
  2. Log in as an administrator.
  3. On the Panopoly Magic settings page, make sure the preview option is set to Single
  4. On the home page, click the Customize button.
  5. Add an "Add text" widget and mark it as reusable.
  6. Save the customized page.
  7. In a separate tab, open the Recent log messages. Clear all messages.
  8. In the home page tab, click Customize again.
  9. Click an Add button and select the category Reusable content.
  10. In the dblog tab, refresh the page. Note there are no PHP notices.
  11. In the home page tab, click to select the reusable widget and show its preview.
  12. In the dblog tab, refresh the page. Note there are 5 PHP notices.

The PHP notices started appearing in release 1.50, which is when the preview callback functions were added.

Comments

cboyden created an issue. See original summary.

cboyden’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB

Looks like there were some properties missing in various places. I've attached a patch that adds the properties. Tested with multiple FPP preview callbacks and also with multiple reusable widgets, in all preview modes. The PHP notices no longer appear and the previews display correctly for each item or FPP widget type.

dsnopek’s picture

Thanks!

+++ b/panopoly_magic.module
@@ -1527,6 +1527,7 @@ function panopoly_magic_preview_callback_fpp($type, $subtype, $plugin, $renderer
+    $fpp->fpid = '';

Why an empty string? This property is usually an integer (or perhaps a string that contains an integer - PHP types are fun :-)). I could see an argument for using either 0 or NULL, but a string feels out-of-place unless there's already some FPP code that does that?

Other than that, this code looks great!

cboyden’s picture

Thanks for the review. Here's an updated patch that uses NULL instead of empty string for the fpid. I wasn't sure whether 0 would end up as an array index or something, and then possibly get its contents mangled if there's more than one FPP involved.

  • dsnopek committed c68e047 on 7.x-1.x
    Update Panopoly Magic for Issue #2995697 by cboyden, dsnopek: PHP...
dsnopek’s picture

Status: Needs review » Fixed

Merged, thanks!

Status: Fixed » Closed (fixed)

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