Problem/Motivation

\Drupal\media\Plugin\Filter\MediaEmbed::applyPerEmbedMediaOverrides() could use to pass NULL to DOMElement::setAttribute()

see https://3v4l.org/IWGqr

$doc = new DOMDocument("1.0");
$node = $doc->createElement("para");
$newnode = $doc->appendChild($node);
$newnode->setAttribute("align", NULL);
var_dump($newnode->getAttribute("align"));

Fix from https://git.drupalcode.org/project/drupal/-/commit/a27bd8682c4eb5d87a55e...

Steps to reproduce

Run core/modules/media/tests/src/Kernel/MediaEmbedFilterTest.php on PHP 8.1

From testOverridesAltAndTitle()

  2x: DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated
    2x in MediaEmbedFilterTest::testOverridesAltAndTitle from Drupal\Tests\media\Kernel

Proposed resolution

Pass empty string instead

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3240955-2.patch791 bytesandypost

Comments

andypost created an issue. See original summary.

andypost’s picture

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

  • catch committed 4efea3f on 9.3.x
    Issue #3240955 by andypost: \Drupal\media\Plugin\Filter\MediaEmbed::...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4efea3f and pushed to 9.3.x. Thanks!

Status: Fixed » Closed (fixed)

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