Problem/Motivation

\Drupal\KernelTests\Core\Render\Element\ActionsTest::getFormId() returns NULL and cause deprecation on PHP 8.1.

Because \Drupal\Core\Form\FormBuilder::prepareForm() calls \Drupal\Component\Utility\Html::getId() with NULL as form ID so mb_strtolower() throws deprecation


 $form['#attributes']['data-drupal-selector'] = Html::getId($form_id);

Steps to reproduce

Run core/tests/Drupal/KernelTests/Core/Render/Element/ActionsTest.php on PHP 8.1

  2x: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated
    2x in ActionsTest::testDropbuttonWithBubbleableMetadata from Drupal\KernelTests\Core\Render\Element

  1x: strrpos(): Passing null to parameter #1 ($haystack) of type string is deprecated
    1x in ActionsTest::testDropbuttonWithBubbleableMetadata from Drupal\KernelTests\Core\Render\Element

Proposed resolution

return string from \Drupal\KernelTests\Core\Render\Element\ActionsTest::getFormId()

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3240960-2.patch510 bytesandypost
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

andypost’s picture

Status: Active » Needs review
FileSize
510 bytes
andypost’s picture

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed 0247f92 and pushed to 9.3.x. Thanks!

  • larowlan committed 0247f92 on 9.3.x
    Issue #3240960 by andypost: \Drupal\KernelTests\Core\Render\Element\...

Status: Fixed » Closed (fixed)

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