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.

CommentFileSizeAuthor
#2 3371959.patch1.78 KBandreic

Comments

andreic created an issue. See original summary.

andreic’s picture

StatusFileSize
new1.78 KB

Attaching patch

cilefen’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

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

andreic’s picture

Thanks, I will try to debug that part.

andreic’s picture

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).

andreic’s picture

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).

andreic’s picture

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.

connbi’s picture

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).

andreic’s picture

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?

tcrawford’s picture

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.

papagrande’s picture

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.

andreic’s picture

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

papagrande’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)
Related issues: +#1255092: url() should return / when asked for the URL of the frontpage

@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 since the [current-page:url:relative] token no longer showed the alias. I ended up injecting the correct tag using hook_metatags_alter().