If the field items array is empty, then the formatter code below will load all products with status=1.... a warning to anyone using commerce_product_load_multiple() with a filter array.
commerce_product_reference_field_formatter_view():
392 // Collect the list of product IDs.
393 $product_ids = array();
394
395 foreach ($items as $delta => $item) {
396 $product_ids[$item['product_id']] = $item['product_id'];
397 }
398
399 $products = commerce_product_load_multiple($product_ids, array('status' => 1));
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | empty-pref-ids-check-1345214-1.patch | 662 bytes | recrit |
Comments
Comment #1
recrit commentedpatch attached adds an empty check after the field items loop.
Comment #2
rszrama commentedNice find! Committing.
For the security conscious - there is no accidental display happening, as even though we load all products (which is a performance drag I'm sure), we still only display products actually included in the $items array... namely, none of them.