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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | easy_breadcrumb-easy_breadcrumb_builder_deprecation-3257776-2.patch | 766 bytes | aerzas |
Issue fork easy_breadcrumb-3257776
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
Comment #2
aerzas commentedHere is a proposition.
Comment #3
greg boggslooks good. Can you send a merge request?
Comment #7
hmendes commentedSorry @Aerzas, I just created a MR from your patch, didn't meant to not give you the credits.
Comment #8
greg boggsComment #10
renatog commentedThat'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
Comment #12
eric_a commentedThis issue seems to have introduced a little regression: #3276229: EasyBreadcrumbBuilder::normalizeText() mishandles string "0"