entity_extract_ids() should produce a NULL if the entity has no ID yet.

However, in hook_field_attach_form() with the product form, I get an empty string.

(Marking as major as it's going to cause problems with #1050872: Integrate with the Flag module, which is how I've encountered it.)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama’s picture

I'm guessing this affects all our entity types then; just need to look in the create method of our controllers to fix 'em.

I don't think anything in Commerce itself is so finicky as to expect NULL vs. ''. I wonder why the code reading this stuff isn't just using empty(). : ?

rszrama’s picture

Status: Active » Needs review
FileSize
2.52 KB

Get 'em, test bot.

Status: Needs review » Needs work

The last submitted patch, 1689538-2.null_ids.patch, failed testing.

rszrama’s picture

Priority: Major » Normal
Status: Needs work » Needs review
FileSize
3.23 KB

Meh, that was a silly assertion.

rszrama’s picture

Status: Needs review » Fixed

I don't see any place in Commerce where we make any assertions against IDs stronger than ==, so NULL or '' won't matter. Going to go ahead and commit the patch in #4.

Status: Fixed » Closed (fixed)

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