Closed (fixed)
Project:
Commerce Core
Version:
7.x-1.x-dev
Component:
Customer
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Mar 2013 at 11:25 UTC
Updated:
27 Feb 2014 at 17:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
rszrama commentedI'm gonna need more information, like what fields are you trying to copy from one to the other. The default behavior itself produces no warnings for me.
Comment #2
adpo commentedI was able to reproduce this error on new commerce kickstart installation, by adding field_position List (text) field on shipping profile, and then using the same field on billing.
Comment #3
warbo commentedThe line mentioned in the error is this:
I've put some printf debugging around it and found:
Since $form_state['order']->data['profile_copy'][$pane_id]['elements'][$field_name][$langcode] is a boolean, we can't put "[$delta]" after it, hence the error.
I've been scouring over our code but can't see anything wrong with the input. I've worked around it so far using an if(is_array()) check. Would be good to know where the real problem lies though.
Comment #4
warbo commentedNot sure if it's related, but some of my SimpleTests which try to checkout are failing in commerce_customer_profile_copy_fields. Drush outputs loads of this:
Test commerce_customer_profile_copy_fields() failed: Undefined index: [error]
profile_copy
Test commerce_customer_profile_copy_fields() failed: Undefined index: [error]
field_email
Test commerce_customer_profile_copy_fields() failed: Undefined index: [error]
field_phone
Test commerce_customer_profile_copy_fields() failed: Undefined index: [error]
customer_profile_billing__c
Test commerce_customer_profile_copy_fields() failed: Undefined index: [error]
field_email
Test commerce_customer_profile_copy_fields() failed: Undefined index: [error]
field_phone
Test commerce_customer_profile_copy_fields() failed: Undefined index: [error]
profile_copy
Test commerce_customer_profile_copy_fields() failed: Undefined index: [error]
field_email
Test commerce_customer_profile_copy_fields() failed: Undefined index: [error]
field_phone
Comment #5
rszrama commentedNot sure. I have issues testing locally as well, but the test bot on d.o never complains.
Comment #6
rszrama commentedBased on #2016045: No array available within address field in the auto copy function, it looks like we should be able to reproduce the warning with the Countries module as well.
Comment #7
mvdve commentedThis is indeed the same issue. Sorry for the duplicate (different line number).
The PHP error is caused by a field in the $form_state array where $langcode is not an array, for example the countries field:
Countries field
Normal text field
The following line can not be executed, because $delta does not exists:
I added an extra array check on the $langcode variable, but is looks like this should be fixed within the Countries module.
Comment #8
checker commentedChanging version
Comment #9
checker commentedJust want to add, this also happens if you are using list (integer) not only list (text) fields.
Comment #10
checker commentedThis patch does not correct the root of the problem but it controls this situation from drupal core with list fields. Just adding an if clause for the missing $delta dimension.
Comment #11
rszrama commentedAlrighty, what was happening in here is that our validate handler was being invoked before another that does data transformation to the field arrays, such as the List (text) field, resulting in the second pass hitting a conflict with data stored in the form state from the first pass.
My proposed solution is attached: clear the copied elements array at the start of the function for the current $pane_id. There's no reason I can see to persist this from invocation to invocation, and resetting this at the start avoids any notices with scalars (the boolean TRUE being set for the field sans delta values) being used as arrays.
Comment #12
checker commentedPatch #11 looks good. I get no warnings and I can complete the order.
Comment #13
rszrama commentedThanks for the test. Committed.
Comment #17
rszrama commented