[D10 PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\path_alias\PathProcessor\AliasPathProcessor->processOutbound() (line 54 of core/modules/path_alias/src/PathProcessor/AliasPathProc

Created on 3 July 2023, 12 months ago
Updated 21 September 2023, 9 months ago

Problem/Motivation

After upgrade to Drupal 10.0.9 and PHP 8.1, this error displays when loading a search api view:

Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\path_alias\PathProcessor\AliasPathProcessor->processOutbound() (line 54 of core/modules/path_alias/src/PathProcessor/AliasPathProcessor.php).

Proposed resolution

Patch.

πŸ› Bug report
Status

Closed: works as designed

Version

10.0 ✨

Component
PathΒ  β†’

Last updated 6 days ago

  • Maintained by
  • πŸ‡¬πŸ‡§United Kingdom @catch
Created by

πŸ‡·πŸ‡΄Romania andreic

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @andreic
  • πŸ‡·πŸ‡΄Romania andreic

    Attaching patch

  • Status changed to Postponed: needs info 12 months ago
  • πŸ‡ΊπŸ‡ΈUnited States cilefen

    This looks like a workaround to some bad input. What are the steps to reproduce?

  • last update 12 months ago
    Custom Commands Failed
  • πŸ‡·πŸ‡΄Romania andreic

    Thanks, I will try to debug that part.

  • πŸ‡·πŸ‡΄Romania andreic

    This is weird, I'm getting the error when accessing paths like taxonomy/term/327.
    I've upgraded to 10.1.1 and now I get:

    Deprecated function: str_starts_with(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\path_alias\PathProcessor\AliasPathProcessor->processOutbound() (line 54 of core/modules/path_alias/src/PathProcessor/AliasPathProcessor.php).

  • πŸ‡·πŸ‡΄Romania andreic

    If I go to admin/structure/taxonomy/manage/tags/overview I also get it:

    Deprecated function: str_starts_with(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\path_alias\PathProcessor\AliasPathProcessor->processOutbound() (line 54 of core/modules/path_alias/src/PathProcessor/AliasPathProcessor.php).

  • πŸ‡·πŸ‡΄Romania andreic

    I've just tested with a clean install of 10.1.1 and when accessing admin/structure/taxonomy/manage/tags/overview it does not display the error.
    It must be something with that particular client.

  • When I install pathauto module and not create alias for node, I will got error message:
    Deprecated function: str_starts_with(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\path_alias\PathProcessor\AliasPathProcessor->processOutbound() (line 54 of core/modules/path_alias/src/PathProcessor/AliasPathProcessor.php).
    Deprecated function: str_starts_with(): Passing null to parameter #1 ($haystack) of type string is deprecated in Drupal\Core\Routing\UrlGenerator->generateFromRoute() (line 309 of core/lib/Drupal/Core/Routing/UrlGenerator.php).
    Deprecated function: rawurlencode(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Routing\UrlGenerator->generateFromRoute() (line 314 of core/lib/Drupal/Core/Routing/UrlGenerator.php).

  • πŸ‡·πŸ‡΄Romania andreic

    I enabled pathauto and created a node without alias on a clean Drupal 10.1.1 site but I couldn't get the error.
    What were your steps?

  • πŸ‡¨πŸ‡­Switzerland tcrawford

    It was (is) a warning (deprecation) and not an error and so you won't see it unless your error reporting is showing warnings. If time permits I will add detailed test instructions. We saw this with 9.5.x. I have not yet tested with 10.1.x, but will do.

  • πŸ‡ΊπŸ‡ΈUnited States PapaGrande

    This happened on a 9.5.x client site after I updated to PHP 8.1. I found an old path for the home page that was missing the alias, i.e. was blank. After deleting the bad alias, the errors went away.

    I'm guessing the alias has been there since Drupal 7.x and PHP 5.x and only became a problem with the upgrade to PHP 8.1.

  • πŸ‡·πŸ‡΄Romania andreic

    I can confirm the cause was empty aliases. In my case, empty taxonomy aliases.
    Obviously, the patch I uploaded is useless at this point.

  • Status changed to Closed: works as designed 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States PapaGrande

    @andeic, thanks for the update. I think we can close this issue and hide the useless patch.

    To follow up on my empty home page alias, after deleting it I ran into other problems with the metatag module and https://www.drupal.org/project/drupal/issues/1255092 πŸ› url() should return / when asked for the URL of the frontpage Needs work since the [current-page:url:relative] token no longer showed the alias. I ended up injecting the correct tag using hook_metatags_alter().

Production build 0.69.0 2024