While looking at the related issue, I got confused whether getOwnerId() could return NULL.

Fago - sitting next to me @ dev days - confirmed it can. So the docs should be fixed.

CommentFileSizeAuthor
#7 2471915-7.patch579 bytesstefan.r
entityownerinterface-getid.patch476 bytesroderik

Comments

roderik’s picture

Status: Active » Needs review

.

jhodgdon’s picture

Hm, really?

The code for all the methods that override this interface method looks basically like this:

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

Can this really be NULL?

fago’s picture

Can this really be NULL?

yep, it can!

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

OK then.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

If we're going to improve the documentation to say this returns a null sometimes shouldn't we take the time to document why.

stefan.r’s picture

<stefan_r> pfrenssen: do we know when the uid field on an entity might be NULL?
<stefan_r> I grepped for usages of this and it looks like it's when the field has not been set, or was explicitly set to NULL in case there was no author, or in case we remove it so non-admin users can send it over REST
<pfrenssen> stefan_r: yes when it has been created programmatically during a test for example
<pfrenssen> stefan_r: nothing stops you from calling Entity::create() and not setting the uid
stefan.r’s picture

Title: Fix EntityOwnerInterface::getOwnerId function comments » Fix EntityOwnerInterface::getOwnerId() documentation
Status: Needs work » Needs review
StatusFileSize
new579 bytes
pfrenssen’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed b7a8acf and pushed to 8.0.x. Thanks!

  • alexpott committed b7a8acf on 8.0.x
    Issue #2471915 by roderik, stefan.r: Fix EntityOwnerInterface::...

Status: Fixed » Closed (fixed)

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