Using the latest -dev of Panelizer in Open Atrium, people are reporting that when they go to the Customize Display tab for their User page, they get a lot of errors:

Notice: Trying to get property of non-object in panels_renderer_standard->init() (line 167 of /opt/development/mpotter/drupal/profiles/openatrium/modules/contrib/panels/plugins/display_renderers/panels_renderer_standard.class.php).
Notice: Undefined property: stdClass::$content_types in panelizer_edit_content_form() (line 467 of /opt/development/mpotter/drupal/profiles/openatrium/modules/contrib/panelizer/includes/common.inc).
Notice: Trying to get property of non-object in panels_edit_display_form() (line 58 of /opt/development/mpotter/drupal/profiles/openatrium/modules/contrib/panels/includes/display-edit.inc).
Notice: Undefined property: stdClass::$layout in panels_edit_display_settings_form() (line 218 of /opt/development/mpotter/drupal/profiles/openatrium/modules/contrib/panels/includes/display-edit.inc).
Notice: Undefined property: stdClass::$hide_title in panels_edit_display_settings_form() (line 231 of /opt/development/mpotter/drupal/profiles/openatrium/modules/contrib/panels/includes/display-edit.inc).
Notice: Undefined property: stdClass::$title in panels_edit_display_settings_form() (line 241 of /opt/development/mpotter/drupal/profiles/openatrium/modules/contrib/panels/includes/display-edit.inc).
...and more...

(that was for the page url /user/7/panelizer/page_manager/content)

Looking into this to try and help, I've narrowed it down to having revisions enabled, but not having any specific revision id available. In PanelizerEntityDefault.class.php at line 2445 there is code like this:

    $form_state = array(
      'entity' => $entity,
      'revision info' => $this->entity_allows_revisions($entity),
      'display cache' => panels_edit_cache_get(implode(':', array('panelizer', $this->entity_type, $entity_id, $view_mode, $revision_id))),
      'no_redirect' => TRUE,
    );

The problem arises when $revision_id isn't set. This causes a side-effect over in panelizer_panels_cache_get() where it does:

  // Extract the entity ID and view mode.
  list($entity_id, $view_mode) = explode(':', $key, 2);

which ends up with a $view_mode of "page_manger:" (trailing colon).

I think this might be related to the fact that the user entity doesn't have a revision value. We *are* using some patches to the Entity API module to enable revision ids on entities, so it's possible those changes are inter-related. However, the API docs for entity_extract_ids() explicitly state that the returned revision id MIGHT be Null, so it seems like the Panelizer code needs to take this possibility into account.

Comments

mpotter’s picture

Status: Active » Needs review
StatusFileSize
new985 bytes

Here is a patch to fix it, but not sure if this is the correct method. Perhaps user panelizer cannot be revisioned and the option for that should be removed?

hefox’s picture

StatusFileSize
new2.71 KB

Original patch doesn't get all the instances where cache key is set

osopolar’s picture

Patch in #2 works for me, thank you mpotter and hefox.

damienmckenna’s picture

Do you have revisions enabled on the user entity?

damienmckenna’s picture

StatusFileSize
new2.53 KB

This changes the remaining item to use array_filter().

damienmckenna’s picture

Status: Needs review » Fixed

This looks entirely reasonable. Thank you both. Committed.

  • DamienMcKenna committed ba0b0ad on 7.x-3.x
    Issue #2514068 by mpotter, hefox, DamienMcKenna: entity_extract_ids()...

Status: Fixed » Closed (fixed)

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

rajab natshah’s picture