Problem/Motivation

Receiving this message on a PHP 8.1 server:

Deprecated function: preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated in Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build() (line 254 of modules/contrib/easy_breadcrumb/src/EasyBreadcrumbBuilder.php)

Steps to reproduce

Upgrade your PHP version to 8.1

Proposed resolution

Edit in /src/EasyBreadcrumbBuilder.php row 254:

from:
$mapValues = preg_split('/[\r\n]+/', $this->config->get(EasyBreadcrumbConstants::REPLACED_TITLES));

to:
$mapValues = !empty($this->config->get(EasyBreadcrumbConstants::REPLACED_TITLES)) ? preg_split('/[\r\n]+/', $this->config->get(EasyBreadcrumbConstants::REPLACED_TITLES)) : [];

CommentFileSizeAuthor
#7 preg-split-3281468-7.patch1.04 KBomkar-pd
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

VynokurovD created an issue. See original summary.

VynokurovD’s picture

Category: Task » Bug report
VynokurovD’s picture

Issue summary: View changes
VynokurovD’s picture

Issue summary: View changes
avpaderno’s picture

Issue tags: -deprecated
avpaderno’s picture

Title: PHP 8.1 Deprecated function: preg_split() » preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated
omkar-pd’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB
sébastien-fr’s picture

I had also the issue.

Patch in #7 solves the problem

greg boggs’s picture

The line of code is too many characters to meet coding standards. Can we break the code up into shorter lines and open a merge request instead of using patches.

https://www.gregboggs.com/drupal-merge-requests/

avpaderno’s picture

Version: 2.0.2 » 2.0.3
Status: Needs review » Needs work
omkar-pd’s picture

Assigned: Unassigned » omkar-pd

Will make changes as per #9.

omkar-pd’s picture

Assigned: omkar-pd » Unassigned
Status: Needs work » Needs review

Made changes as per #9. needs review if it's working properly.

greg boggs’s picture

Status: Needs review » Fixed

Thank you thank you!

  • Greg Boggs committed 9366fbc on 2.x authored by omkar-pd
    Issue #3281468 by omkar-pd, VynokurovD, apaderno, vinyl_roads, Greg...

Status: Fixed » Closed (fixed)

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