Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #2
stox CreditAttribution: stox commentedComment #3
mpotter CreditAttribution: mpotter at Phase2 commentedAs 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.
Comment #4
stox CreditAttribution: stox commentedThanks Mike, will give that a try.
Comment #5
stox CreditAttribution: stox commentedHey 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.
Comment #6
mpotter CreditAttribution: mpotter at Phase2 commentedI 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:
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.
Comment #7
Jorrit CreditAttribution: Jorrit at nCode for DOM Digital Online Media GmbH commentedMaybe 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.