Download & Extend

product form has entity ID as '' rather than NULL

Project:Drupal Commerce
Version:7.x-1.x-dev
Component:Product
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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.)

Comments

#1

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(). : ?

#2

Status:active» needs review

Get 'em, test bot.

AttachmentSizeStatusTest resultOperations
1689538-2.null_ids.patch2.52 KBIdleFAILED: [[SimpleTest]]: [MySQL] 3,588 pass(es), 1 fail(s), and 0 exception(s).View details

#3

Status:needs review» needs work

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

#4

Priority:major» normal
Status:needs work» needs review

Meh, that was a silly assertion.

AttachmentSizeStatusTest resultOperations
1689538-4.null_ids.patch3.23 KBIdlePASSED: [[SimpleTest]]: [MySQL] 3,587 pass(es).View details

#5

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.

#6

Status:fixed» closed (fixed)

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

nobody click here