Problem/Motivation

getCleanSeparators() in AliasCleaner class uses strlen() to check for the length of the string. When config has a value of NULL, the strlen(NULL) check issues a warning in PHP8.1.

Steps to reproduce

Run tests in PHP 8.1

Proposed resolution

Replace 1 line `if (strlen($separator)) {` with `if (!empty($separator)) {`

Using strlen() to check for emptiness is not a good idea anyway - it is not the purpose of this function.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Issue fork pathauto-3313566

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

alex.skrypnyk created an issue. See original summary.

berdir’s picture

those configs are expected to be empty strings not null, if some are null, especially ignore words then you likely reverted some previous update functions, I would expect that resaving the config page should fix that, if the config page is even working. if not you'll need to change it manually.

srijeeta’s picture

Assigned: Unassigned » srijeeta
srijeeta’s picture

StatusFileSize
new1.32 KB

Hi,

Added a patch for strlen issue, also ran rector to check the compatibility with php 8.1

srijeeta’s picture

Status: Active » Needs review
damienmckenna’s picture

Assigned: srijeeta » Unassigned
Status: Needs review » Needs work

The patch doesn't include the MR's changes and seems like it's solving a different issue?

As a reminder, please set the "assigned" field back to "unassigned" when you're finished with an issue. Thank you.

bharath-kondeti’s picture

Assigned: Unassigned » bharath-kondeti
bharath-kondeti’s picture

Assigned: bharath-kondeti » Unassigned
Lingamurthy’s picture

StatusFileSize
new406 bytes

Using php 8 coding syntax

anweshasinha’s picture

StatusFileSize
new424 bytes

Hi,
Added patch for the issue according to php 8.1.22 standard. Please review the patch

adeshsharma’s picture

StatusFileSize
new428 bytes

Modified operator content check

adeshsharma’s picture

Status: Needs work » Needs review
damienmckenna’s picture

For completeness sake, #12 would exclude certain characters from being allowed, e.g. a zero or a space. While, in practical terms I suspect these exceptions should be allowed (who would use "0" or a space as a separator in their URLs anyway?), I think it might be best to make sure the string is being vetted the same as the separator form field itself.

berdir’s picture

Status: Needs review » Needs work

Yes, seems like the MR is the best solution for this.

Per #3, this should only happen if you have incomplete settings, I've fixed some issues that caused fatal errors and prevented users from even changing the settings, but that's not the case here. Resaving the settings form should IMHO get rid of this problem.

The MR can't be rebased through the UI it seems, please do that manually.

solideogloria’s picture

!empty($string) isn't a correct way to check for a string's emptiness.

empty('0') === TRUE

Still, as Damien suggested, who would use that as a separator?

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

mably’s picture

Version: 8.x-1.11 » 8.x-1.x-dev
Status: Needs work » Needs review

MR has been rebased.

solideogloria’s picture

Status: Needs review » Needs work
mably’s picture

Status: Needs work » Needs review

  • mably committed 6e7d6349 on 8.x-1.x authored by alex.skrypnyk
    fix: #3313566 strlen(): Passing null to parameter #1 when using PHP 8.1...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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