Problem/Motivation

During the build of the breacrumb, NULL values can be passed to EasyBreadcrumbBuilder::normalizeText, from EasyBreadcrumbBuilder::getTitleString for example, which triggers a deprecation in PHP 8.1:
Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->normalizeText() (line 888 of modules/contrib/easy_breadcrumb/src/EasyBreadcrumbBuilder.php).

Proposed resolution

We should return early an empty string if there is nothing to normalize and update the method documentation.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Aerzas created an issue. See original summary.

aerzas’s picture

Status: Active » Needs review
Issue tags: +Needs review
StatusFileSize
new766 bytes

Here is a proposition.

greg boggs’s picture

looks good. Can you send a merge request?

hmendes made their first commit to this issue’s fork.

hmendes’s picture

Sorry @Aerzas, I just created a MR from your patch, didn't meant to not give you the credits.

greg boggs’s picture

Status: Needs review » Fixed

  • Greg Boggs committed e5f5841 on 2.x authored by Aerzas
    Issue #3257776 by Aerzas: PHP 8.1 EasyBreadcrumbBuilder::normalizeText...
renatog’s picture

Status: Needs review » Fixed
Issue tags: -Needs review

That's great. It's working. Thank you very much, everyone. I was testing here and it was moved to the dev branch 2.x here: https://git.drupalcode.org/project/easy_breadcrumb/-/blob/2.x/src/EasyBr...

But the status is still as "Needs review" I think we can close that as fixed right?

If there is a reason to keep open we can do this without problems

Status: Fixed » Closed (fixed)

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

eric_a’s picture

This issue seems to have introduced a little regression: #3276229: EasyBreadcrumbBuilder::normalizeText() mishandles string "0"