DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated on PHP 8.1

Created on 28 September 2023, about 1 year ago
Updated 8 December 2023, 11 months ago

Problem/Motivation

We're getting this exception for some formatter configurations on PHP 8.1:

Deprecated function: DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated in Drupal\svg_formatter\Plugin\Field\FieldFormatter\SvgFormatter->viewElements()

Steps to reproduce

In the formatter settings, check "Output SVG inline" and "Set image dimensions." and set a width and/or height.

inline is false by default, but the default value for apply_dimensions is TRUE and the width and height are integer 100 by default, so this should be visible as soon as you enable inline.

Proposed resolution

Cast the values to string.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇩🇪Germany FeyP

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

Comments & Activities

Production build 0.71.5 2024