backdrop-contrib / commerce

GNU General Public License v2.0
3 stars 5 forks source link

commerce_file_field_insert() and commerce_file_field_update() should check if $items is false #8

Closed herbdool closed 1 month ago

herbdool commented 1 month ago

Warning: foreach() argument must be of type array|object, bool given in BackdropCommerceEntityController->commerce_file_field_insert() (line 272 of /app/httpdocs/modules/commerce/includes/commerce.controller.inc).

It seems that commerce_file_field_insert() is getting the $items loaded by field_get_items() but not checking if there are no items of that field type. Probably can just skip if there are no items.

elisseck commented 1 month ago

Thank you! I was able to reproduce this and it should be resolved in 5da8eaf5625bc784b0075a160ed07f2105bfca45

herbdool commented 1 month ago

@elisseck I added a PR to also update it for commerce_file_field_update(). In this case it's updating the attached files and might get passed NULL which should be treated as an empty array to confirm all files have been removed.