• Hi,

    I have upgraded to PHP 8.1 and since the update I am receiving the following deprecated warning:

    PHP Deprecated:  strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in plugins/woo-permalink-manager/src/Frontend/Frontend.php on line 100

    Please let me know if you need additional information in order to fix this issue.

    Thank you,
    Alex

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Alex,

    Greetings! Thanks for reaching out to us.

    Yes, please provide additional information on how can we reproduce the issue aside from using PHP 8.1 version?

    In the meantime, can you please confirm that downgrading your PHP version to a lower version resolves the issue?

    Looking forward to your response.

    Thread Starter Alex Spataru

    (@alexandrubr)

    Hi,

    I checked the line with the issue. This is the line with the issue:

    $commentsPosition = strpos( $slug, 'comment-page-' );

    I have tried the following code for testing purposes

    $data = strpos( null, 'comment-page-' );

    While running the test, I got the same PHP Deprecated warning.

    This is a straightforward fix: just make sure the variable $slug has the data type of string and the issue should be gone.

    If we take a look at the php.net documentation we see this, which confirms the function expects a different data type (string, instead of null).

    strpos(string $haystack, string $needle, int $offset = 0): int|false

    Hi @alexandrubr,

    Thanks for the details. I’ve escalated this issue to our development team.

    We’ll be sure to dive deep into this matter and solve it as soon as possible. We’ll get back to you once the issue has been sorted out.

    Once again, thanks for bringing this to our attention. Have a great day ahead.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP Deprecated in 8.1’ is closed to new replies.