Warning on AJAX call when changing the breakpoint_group field value of a responsive image style

Created on 4 January 2022, over 2 years ago
Updated 20 March 2023, over 1 year ago

Problem/Motivation

Warning: foreach() argument must be of type array|object, null given in core/modules/responsive_image/src/ResponsiveImageStyleForm.php (line 231)

Steps to reproduce

I get this warning in the AJAX response when changing the breakpoint_group field value of an existing responsive image style, from "responsive_image" to "my_site.breakpoints".

Proposed resolution

In ResponsiveImageStyleForm::validateForm(), just after $form_state->unsetValue('keyed_styles');, call return;.

Or wrap the following foreach in an else statement. Or in an if statement checking that it's set.

Or set value to an empty array instead of unsetting it.

I'm not sure what's the best fix.

Remaining tasks

Agree on what to do and do it?

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

No need, it's a straightforward PHP bug fix.

🐛 Bug report
Status

Fixed

Version

9.5

Component
Responsive image 

Last updated 12 days ago

Created by

🇫🇷France GaëlG Lille, France

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024