Problem/Motivation

When a module implements hook_toolbar with a #type => 'toolbar_item' but without a 'tab', the implementation triggers a PHP deprecation notice on PHP8.1:

Deprecated function: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Html::escape() (line 424 of core/lib/Drupal/Component/Utility/Html.php).

Proposed resolution

Fix the deprecation notice

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

CommentFileSizeAuthor
#2 3259807-2.patch984 bytesidebr
#2 3259807-2-test-only.patch507 bytesidebr

Comments

idebr created an issue. See original summary.

idebr’s picture

Status: Active » Needs review
StatusFileSize
new507 bytes
new984 bytes

Attached patch fixes the deprecation notice on PHP8.1

anneke_vde’s picture

Status: Needs review » Reviewed & tested by the community

I tested this with PHP8.1, the deprecation notice is gone when I applied the patch.

  • catch committed b9e078a on 10.0.x
    Issue #3259807 by idebr, anneke_vde: #type => 'toolbar_item' without a...

  • catch committed 6e3d4a3 on 9.3.x
    Issue #3259807 by idebr, anneke_vde: #type => 'toolbar_item' without a...
  • catch committed 0679b0f on 9.4.x
    Issue #3259807 by idebr, anneke_vde: #type => 'toolbar_item' without a...
catch’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed b9e078a and pushed to 10.0.x. Thanks! Also cherry-picked to 9.4.x and 9.3.x.

Status: Fixed » Closed (fixed)

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

liam morland’s picture

Issue tags: -PHP8.1 +PHP 8.1