When adding a File, Image, or Spotlight widget as an editor, I get a PHP notice if I set the Title.

Error message:
Notice: Undefined property: stdClass::$view_access in PanelsPaneController->access() (line 77 of /www/profiles/panopoly/modules/contrib/fieldable_panels_panes/includes/PanelsPaneController.class.php).

To reproduce:

  1. Log in as a user with the Editor role
  2. Go to any panelized page (for example, /content/great-vegetables if you have Demo installed)
  3. Click Customize this page
  4. Click an Add new pane button
  5. Choose Add image
  6. Start typing in the Title field under General Settings
  7. Note that when Live Preview finishes, there is a PHP notice

The message goes away after you click Save and exit the widget modal.

The error does not appear on any other widget types - only widgets with a file upload field. And it does not appear for users with the administrator role.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dsnopek’s picture

Component: Widgets » Magic
Status: Active » Needs review
FileSize
725 bytes

I'm not sure why this only happens on widgets with an image field, but I think I know why it only happens on new widgets and when you're not an admin user.

First of all, it only does this access check when you're not an admin user. And the $entity->view_access property is set when loading the FPP from the database, but in the case of live preview on a new widget, we're never loading it from the database.

So, all we need to do is set $entity->view_access = NULL (the default value) if it's not already set, just before calling fieldable_panels_panes_access('view', $entity).

Here's a patch that works in my testing.

  • dsnopek committed 3f12ff7 on 7.x-1.x
    Update Panopoly Magic for Issue #2463389 by dsnopek: PHP notice when...
dsnopek’s picture

Status: Needs review » Fixed

Commited!

Status: Fixed » Closed (fixed)

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