For multi-value Amazon Item fields using the Amazon ASIN Text field widget, asin_field_widget_element_validate() is called once for each field shown on the add/edit form. For each call it iterates over each field on the form, validating each field multiple times and causing redundent lookups.
The attached patch addresses the issue, and seems to properly catch invalid input in all submitted fields.
It also addresses the issue where such validations would cause PHP 5.4 and newer to throw the following warning:
Warning: Illegal string offset 'asin' in asin_field_widget_element_validate() (line 212 of /path/to/drupal/sites/all/modules/amazon/asin/asin.module).
The above behavior is documented here:
http://docs.php.net/manual/da/language.types.array.php
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | amazon-asin_field_widget_element_validate_causes_redundent_lookups-2317539-2.patch | 1.37 KB | generalredneck |
| asin.module.patch | 1.27 KB | brucebertrand |
Comments
Comment #1
smitty commentedThis patch seems to work fine. At least the Warning "Illegal string offset" disappears ...
My only problem was: the patch sems to be coded in the wrong direction. I think it should be:
Comment #2
generalredneckYou are right, I was able to get it to apply with
patch -p1 -R < asin.module_0.patch. Additionally the patch had to be applied inside the asin module directory where typically on projects such as this one with multiple modules, you create/apply at the project level so that git, drush, and composer can all work with the patches in an automated way. Attaching the corrected patch.Thank you for the work!
Comment #3
marcelovani