Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This patch solves the problem in commerce_line_item_field_widget_form when line_items array is empty.
Comment | File | Size | Author |
---|---|---|---|
#7 | commerce-line-item-load-empty-array.patch | 802 bytes | michee.lengronne |
#7 | commerce-line-item-load-empty-array.patch | 802 bytes | michee.lengronne |
#1 | commerce-line-item-load-empty-array.patch | 799 bytes | michee.lengronne |
commerce-line-item-load-empty-array.patch | 802 bytes | michee.lengronne | |
Comments
Comment #1
michee.lengronneHum, I think this one is better.
Comment #2
rszrama CreditAttribution: rszrama commentedTagging. Patch will need review for code formatting.
Comment #3
mglamanShouldn't commerce_line_item_load_multiple() return an empty array from entity_load() anyways?
Comment #4
rszrama CreditAttribution: rszrama commentedIt's actually a lovely "feature" that it will return literally every entity of the given type. Not sure what drove that decision. : P
Comment #5
mglamanMarking this as RTBC, then. Looks good, will properly handle empty line items.
Only change is we could make it
But that's super nitpick, and broken out it's easier to read logic going on here and assume why we're doing this check.
Comment #6
rszrama CreditAttribution: rszrama commentedNit picking is good. : D
I think we generally prefer the if / else block over the ternary operator. We do need to fix the code style though to remove the extra line of whitespace and put the curly brace before the else on a line by itself.
Comment #7
michee.lengronneThe code style is normally fixed now. It seemed to be uploaded twice (weird).
Comment #9
mglaman