Under some circumstances that I haven't quite nailed down, entities have a UID field but the field is empty; attempts to load using that value results in a Notice. For whatever reason, this doesn't seem to happen if I am using a highly privileged account (but shows up while testing more locked-down roles).

Notice: Trying to get property 'entity' of non-object in Drupal\eck\Entity\EckEntity->getOwner() (line 32 of modules/contrib/eck/src/Entity/EckEntity.php).
Drupal\eck\Entity\EckEntity->getOwner() (Line: 41)
Drupal\eck\Entity\EckEntity->getOwnerId() (Line: 79)
Drupal\eck\EckEntityAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105)

Comments

thudfactor created an issue. See original summary.

elfin_john’s picture

StatusFileSize
new518 bytes
romixua’s picture

Assigned: elfin_john » romixua
Issue tags: +epam-contrib-2019.03
romixua’s picture

Assigned: romixua » Unassigned
Issue tags: -epam-contrib-2019.03
manuel.adan’s picture

Title: Null entity inside EckEntity.getOwner() » Non-object notices at EckEntity::getOwner() when the uid field exists but it is empty
Status: Active » Needs review
StatusFileSize
new773 bytes
new657 bytes

#2 does not prevent NULL response from getOwner, but silences the notify in case uid is empty. A quick way is:

return $this->get('uid')->entity;

This automatically takes the first value (uid is not multivalue anyway) and evaluates to NULL if the field is empty. The same happens in the getOwnerId method. If the uid field is empty, getOwner and getOwnerId should also return NULL.

Focusing this issue on that. About why the uid field was empty, more indications are needed to help on that; open a new issue if something else found.

heathergaye’s picture

Re-roll of previous patch, which no longer applies.

pifagor’s picture

Status: Needs review » Reviewed & tested by the community

  • pifagor committed 54fef0a on 8.x-1.x authored by heathergaye
    Issue #3020141 by manuel.adan, thudfactor, heathergaye, Romixua, pifagor...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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