Currently, commerce_entity_reference_delete() isn't rekeying $items properly. So, for example, if we have 6 items keyed 0 through 5 and we try to remove the first one, we end up with an array with keys 1 through 5.
The specific problem that I'm observing because of this is that when I delete the line item on an order and then view the order, the commerce_line_items field appears to be empty. Something somewhere must be checking whether $items[0] is empty, but I haven't quite tracked that down yet.
Comments
Comment #1
serialjaywalker commentedThe attached patch adds a call to array_values().
Updated: Oops, this patch did more than I thought. I'll post a new one shortly.
Comment #2
serialjaywalker commentedTry this patch.
Comment #3
damien tournoud commentedThanks for the patch.
I merged the attached variation of it into 7.x-1.x.
Comment #4
rszrama commentedThanks for the fix. After thinking about it, I'm pretty sure the fact that I wasn't rekeying was just a relic of this function's prior dependence on entity_metadata_wrapper(). When I got rid of that, we should've added the code to rekey (and obviously we should've had a solution before - can't remember what it was about the wrapper that kept me from doing so).
And kudos to Damien on the assist. : )
Comment #5
rszrama commentedOh, actually, Damien, I don't see this when I pull. Perhaps you forgot to push? I won't recommit this unless I hear from you that you actually didn't get it in. Setting to RTBC so we don't forget to get it in.
Also, for posterity's sake - rekeying is exactly what happens when you remove an item from a multi-value field. Just confirmed locally w/ a little text field.
Comment #6
rszrama commented