I've experienced this in beta 10 as well as HEAD today.
STEPS TO REPRODUCE:
- Enable responsive images module.
- Create a responsive image style
- Create a view that displays fields and pulls in the image field.
- Set the image field formatter to "Responsive Image" and select the responsive image style you created
- Save the view, create some content with images.
- View the view. I get Fatal error: Unsupported operand types in /d8/core/modules/responsive_image/responsive_image.module on line 118
My workaround is to change
$attributes += $variables['item_attributes'];
to
if (is_array($variables['item_attributes'])){
$attributes += $variables['item_attributes'];
}
but I suspect the real fix is further upstream.
Attached is the config for the responsive image style and view I created testing this on HEAD today.
Beta phase evaluation
Comments
Comment #1
floydm commentedComment #2
floydm commentedLooking in my exported view, I'm noticing the responsive image style isn't specified. I just went in, edited my view again, verified the 'Test' responsive image style was selected, and saved. At that point I checked the view export and now see:
Nevertheless, I'm still getting the unsupported operand type error, even after cache clear.
Comment #3
MarkusDBX commentedI can confirm this. I get the same problem.
Comment #4
dawehnerThat sounds at least major for me.
Comment #5
googletorp commenteditem_attributes is optional and fallback value is NULL, so the code should check for this.
Comment #6
attiks commentedNice catch, RTBC unless we need an explicit test for this?
Comment #7
googletorp commentedComment #8
googletorp commentedI don't think it makes sense to add a test case for this.
Comment #9
alexpottWe definitely should add a test for this.
Comment #10
googletorp commentedAdd test only patch - this should fail.
Comment #11
googletorp commentedCombined the patch and test case, this should pass.
Comment #15
googletorp commentedFixes the test, missed the src folder.
Comment #16
googletorp commentedThis should fail properly now
Comment #17
googletorp commentedCombined patches from #5 and #16
Comment #20
alexpottIs it really necessary to add this test plugin?
Comment #21
googletorp commented@alexpott If we really want to test this, we need to render a responsive image, element without item_attributes set. I figured, that this would be the easiest way to do it.
Comment #22
floydm commentedTeeny change to the patch from #17 to fix a namespace issue.
Still failing with Drupal\Core\Config\Schema\SchemaIncompleteExceptions, but getting closer.
Comment #24
justachris commentedMarked #2506511: Responsive image bug in Views module when use with fields as duplicate of this issue.
Comment #25
googletorp commentedShould work now with test and all.
Comment #28
darol100 commentedThis is a re-roll of the patch #25. I have test it out and it works fine.
Comment #30
paulmckibbenFYI, the same "unsupported operand types" error also occurs when displaying an image field's default value. That is:
- In a content type, create an image field, and specify a default image.
- Make sure the display mode for the field uses a responsive image.
- Create a node of the above content type, and do not set the image field (keep at the default value).
- When you display the node, this same error occurs.
Comment #31
googletorp commented#28 Please make sure when making patches, that your editor is setup to use soft tabs (2 spaces). Most of the code was indented incorrectly.
Comment #32
googletorp commentedThe field formatter was also placed incorrectly, fixed that as well.
Comment #34
mbayntonConfirmed this fixes the issue, agree with solution, and don't personally know a better way to tickle this issue in tests than that.
Comment #36
webchickNice find! Thanks a lot for the test, too.
Committed and pushed to 8.0.x.