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

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug (fatal error)
Issue priority Major because it's a fatal error with a workaround (don't use responsive image in views)

Comments

floydm’s picture

Issue summary: View changes
floydm’s picture

Looking 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:

  settings:
    responsive_image_style: test
    image_link: ''

Nevertheless, I'm still getting the unsupported operand type error, even after cache clear.

MarkusDBX’s picture

I can confirm this. I get the same problem.

dawehner’s picture

Priority: Normal » Major
Issue tags: +VDC

That sounds at least major for me.

googletorp’s picture

Status: Active » Needs review
StatusFileSize
new799 bytes

item_attributes is optional and fallback value is NULL, so the code should check for this.

attiks’s picture

Status: Needs review » Reviewed & tested by the community

Nice catch, RTBC unless we need an explicit test for this?

googletorp’s picture

Issue summary: View changes
googletorp’s picture

I don't think it makes sense to add a test case for this.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

We definitely should add a test for this.

googletorp’s picture

Status: Needs work » Needs review
StatusFileSize
new2.68 KB

Add test only patch - this should fail.

googletorp’s picture

StatusFileSize
new3.46 KB

Combined the patch and test case, this should pass.

The last submitted patch, 10: TEST-ONLY-2483357-11.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 11: fatal_unsupported-2483357-11.patch, failed testing.

googletorp’s picture

StatusFileSize
new2.69 KB

Fixes the test, missed the src folder.

googletorp’s picture

Status: Needs work » Needs review
StatusFileSize
new2.69 KB

This should fail properly now

googletorp’s picture

StatusFileSize
new3.47 KB

Combined patches from #5 and #16

The last submitted patch, 16: TEST-ONLY-2483357-16.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 17: fatal_unsupported-2483357-17.patch, failed testing.

alexpott’s picture

+++ b/core/modules/responsive_image/tests/modules/responsive_image_test_module/src/Plugin/Field/FieldFormatter/ResponsiveImageTestFormatter.php
@@ -0,0 +1,38 @@
+class ResponsiveImageTestFormatter extends ResponsiveImageFormatter {

Is it really necessary to add this test plugin?

googletorp’s picture

@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.

floydm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.52 KB
new174 bytes

Teeny change to the patch from #17 to fix a namespace issue.

Still failing with Drupal\Core\Config\Schema\SchemaIncompleteExceptions, but getting closer.

Status: Needs review » Needs work

The last submitted patch, 22: fatal_unsupported-2483357-22.patch, failed testing.

googletorp’s picture

Status: Needs work » Needs review
StatusFileSize
new3.57 KB
new4.35 KB
new841 bytes

Should work now with test and all.

The last submitted patch, 25: fatal_unsupported-2483357-25-TEST-ONLY.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 25: fatal_unsupported-2483357-25.patch, failed testing.

darol100’s picture

Status: Needs work » Needs review
StatusFileSize
new5.42 KB
new6 KB

This is a re-roll of the patch #25. I have test it out and it works fine.

Status: Needs review » Needs work

The last submitted patch, 28: 2483357-Fatal-Unsupported-operand-28.patch, failed testing.

paulmckibben’s picture

FYI, 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.

googletorp’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new4.21 KB
new5.06 KB

#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.

googletorp’s picture

StatusFileSize
new4.32 KB
new2.95 KB

The field formatter was also placed incorrectly, fixed that as well.

The last submitted patch, 31: fatal_unsupported-2483357-31.patch, failed testing.

mbaynton’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed this fixes the issue, agree with solution, and don't personally know a better way to tickle this issue in tests than that.

The last submitted patch, 15: TEST-ONLY-2483357-15.patch, failed testing.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Nice find! Thanks a lot for the test, too.

Committed and pushed to 8.0.x.

  • webchick committed 793d9a5 on 8.0.x
    Issue #2483357 by googletorp, floydm, darol100, alexpott, paulmckibben:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.