This is a very obscure bug in commerce_line_item_manger_validate which does not affect normal operation as far as I can tell. I only came across it because I have added a new entity to my order definition called 'Booking Information' and wanted to manged booking information items (eg. guest names, dietary requirements etc.) in the same way as line items are managed. The problem is that the line item manager (in commerce_line_item_manger_validate) uses array_pop on the triggering element ($form_state['triggering_element']['#parents']) even if it is NOT handling the triggering button. Since array_pop removes the button's ident from $form_state no other part of the form can see the triggering element, particularly another part of the form that is adding different types of items.

I cannot see a reason to use array_pop in these circumstances and it should be replaced with end() to get the last element but leave the data in $form_state for other parts of the form.


rszrama’s picture

Status: Active » Fixed

Wow, excellent find. I can only imagine how difficult this was to track down, so I appreciate you digging it up and posting it. : )

I searched around for other uses of array_pop() and I'm pretty sure the other three places are legitimate uses of the function, so I've just committed your recommended change as is.


Status: Fixed » Closed (fixed)

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