After deleting a space I get the following error on all admin pages:

Notice: Trying to get property of non-object in entity_metadata_no_hook_node_access() (line 688 of /profiles/openatrium/modules/contrib/entity/modules/callbacks.inc).

The error repeats 30-40 times.

Steps to reproduce:

  • Create space (I created a space logged in as admin).
  • Go to admin/content and delete space.

I have replicated this on two fresh installs on my local machine and on pantheon, it happens every time.

I've taken the following steps to try to resolve it without success:

  • Rebuilt content access permissions
  • Cleared cache
  • Run cron

Comments

stox created an issue. See original summary.

stox’s picture

Priority: Major » Normal
mpotter’s picture

As a work around, the correct way to delete a space is to visit the space, click the Edit button and then click the Delete button. This will properly run the Batch API process to handle content within the space. I don't know if deleting via the admin/content page triggers this extra code, but will look into it.

stox’s picture

Thanks Mike, will give that a try.

stox’s picture

Hey Mike

I tried the workaround you suggested on a fresh install and I get the same thing. Come to think of it, I have deleted the space in that way on a previous test and the same thing happened.

mpotter’s picture

I tracked down the problem. What is happening is that deleting a space doesn't clear out the "current space" context set in the session. When Organic Groups tries to check the current context it has this code:

      $group = entity_load_single($group_type, $check_gid);
      if (!$check_access || entity_access('view', $group_type, $group)) {

The entity_load_single() function returns "false" because the group no longer exists. But the entity_access() function only checks if the $group isset() rather than checking empty().

So either the Entity API module would need to change isset() to !empty(), or the OG Context module would need to check $group before calling entity_access.

I might also be able to do something in Atrium to clear the session context if the current space node is deleted. Maybe somebody could help with a patch for that?

Edited: Oh, so the workaround is to either a) not delete the current space (the last space you visited), and/or b) switch to a different space that wasn't deleted. Then these messages will go away. Also, these are just "Notice" messages and not actual "Error" messages.

Jorrit’s picture

Maybe the implementation has changed since last year, but group content is deleted via the Drupal queue system (i.e.: on cron) and not via de Batch API.

As og prefers GitHub over Drupal, I have created a pull request over there to add a check to og_context_determine_context(): https://github.com/Gizra/og/pull/340.

The link to the patch is https://patch-diff.githubusercontent.com/raw/Gizra/og/pull/340.patch.