Problem/Motivation
entity_metadata_taxonomy_access() sets NULL as the default argument value for $entity; however, the function doesn't actually handle situations where $entity = NULL.
E.g.
case "delete":
if ($entity_type == 'taxonomy_term') {
return user_access("delete terms in $entity->vid", $account);
}
break;
The above code will result in the following notice if $entity = NULL:
Notice: Trying to get property of non-object in entity_metadata_taxonomy_access() (line 827 of /var/www/rovdev/sites/all/modules/entity/modules/callbacks.inc).
Proposed resolution
Check for $entity before trying to access its properties.
E.g.
case "delete":
if ($entity_type == 'taxonomy_term' && $entity) {
return user_access("delete terms in $entity->vid", $account);
}
break;
Remaining tasks
Submit patch
- Community review
User interface changes
None
API changes
Noe
Data model changes
None
Release notes snippet
None
Original report by sano
#2160355-20: Trying to get property of non-object in entity_metadata_user_access()
Comments
Comment #2
chris burge commentedPatch attached.
Comment #3
shaunole commentedReroll of patch for Drupal 7.83 and Entity 7.x-1.10.
Comment #4
shaunole commentedThe previous patch had incorrect paths to the callbacks.inc file. This one should work.
Comment #5
shaunole commentedRenaming the patch file and re-uploading.
Comment #6
shaunole commentedCorrecting syntax error in patch file. No substantial changes were made. Apologize for all of the posts as this should have been caught on the first one.
Comment #7
shaunole commented