When a non-admin user with "create fieldable panels pane" permission, and not "administer fieldable panels panes" permission goes to /admin/structure/fieldable-panels-panes/manage/fieldable_panels_pane/add an error is thrown.

Notice: Trying to get property of non-object in PanelsPaneController->access() (line 73 of C:\www\sandbox\sites\all\modules\fieldable_panels_panes\includes\PanelsPaneController.class.php).

This was introduced with commit d29b81b http://cgit.drupalcode.org/fieldable_panels_panes/commit/?id=d29b81b
to resolve issues https://www.drupal.org/node/2283165 and https://www.drupal.org/node/2225125

$entity will be a string when fieldable_panels_panes_access() is called from fieldable_panels_panes_content_type_create_access() or from any menu item using %fieldable_panels_pane_type since fieldable_panels_pane_type_load() returns a string.

One approach would be to use the format of the Entity API's access callback functions where you have a fourth parameter of $entity_type, but I've gone for the node_node_access() approach instead and test for $entity being a string to then be able to set an $entity_type variable.

Comments

Adrian Richardson’s picture

Adrian Richardson’s picture

Status: Active » Needs review
marty2081’s picture

Status: Needs review » Reviewed & tested by the community

This patch works and needs to be comitted as soon as possible since this breaks basic functionality.

In our case we had issues with the Panels In Place Editor not showing any fieldable panels panes in the add pane modal when the user doest not have the 'administer fiedable panels panes' permission. It turns out to be the same issue as described in this issue description. The patch fixes the case that the $entity variable is a string containing the entity type instead of an object.

Helrunar’s picture

I can confirm that the patch is needed and working.

chris burge’s picture

I can confirm the error reported by @Adrian Richardson. Patch #1 resolves the issue.

damienmckenna’s picture

Status: Reviewed & tested by the community » Needs work

Thank you for the patch and for reviewing it. I've got a small request - you should only use a variable named "$entity_type" when talking about different types of entities, so could you please update the patch to use the correct variable name "$bundle"? Thanks.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new2.05 KB

A minor tweak to change $entity_type to $bundle, etc.

Status: Needs review » Needs work

The last submitted patch, 7: fieldable_panels_panes-n2302931-7.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new2.05 KB

Left in a small syntax bug.

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks Adrian!

Status: Fixed » Closed (fixed)

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