For #1710850: Deploy RestWS for D7 project issue JSON, issues assigned to anonymous, an entityreference field to user 0, have $property->value() === FALSE, which triggers this notice en entity module:

Notice: Trying to get property of non-object in entity_metadata_user_access() (line 702 of /home/drumm/entity/modules/callbacks.inc).

Blocking

CommentFileSizeAuthor
#3 entity-access-notice-2186603-3.patch678 bytesklausi
#1 2186603.diff499 bytesdrumm

Comments

drumm’s picture

StatusFileSize
new499 bytes

The attached patch works around the issue.

drumm’s picture

Status: Active » Needs review
klausi’s picture

Title: entityreference to anonymous user causes notice » entityreference to anonymous user causes notice with access()
Project: RESTful Web Services » Entity API
Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: Code » Entity property wrapper
StatusFileSize
new678 bytes

This is not really the fault of RESTWS, the entityAccess() method of EntityDrupalWrapper invokes entity_access() with $entity as FALSE, which is not supported by the API. Either $entity is an object or NULL, but not FALSE. isset(FALSE) will return TRUE, so the access callback thinks it deals with an object, which results in the notice.

Patch attached to fix entityAccess().

TODO: test case, any volunteers?

drumm’s picture

Issue tags: +affects drupal.org
drumm’s picture

Status: Needs review » Reviewed & tested by the community

#3 looks good in my testing.

yesct’s picture

Issue summary: View changes
drumm’s picture

yesct’s picture

@fago do you want tests for this?

fago’s picture

Status: Reviewed & tested by the community » Fixed

Good catch, thanks committed.

@tests: I'd appreciate it, though imo it should not block the fix as tests do not cover any edge case yet anyway. But of course I'd highly appreciate test coverage to make sure it doesn't break again!

Status: Fixed » Closed (fixed)

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