Problem/Motivation

PHP 8.1 introduces a deprecation for passing null to non-nullable parameters of built-in functions.

As a result, the use of explode() in commerce_checkout_paths_url_outbound_alter results in the following error:

PHP 8.1 Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated

Steps to reproduce

This error appears anytime that the module is enabled.

This is because template_preprocess_page() in includes/theme.inc has the line $variables['front_page'] = url();. Calling url() with no parameters leads to hook_url_outbound_alter() being passed NULL values for $path and $original_path.

Proposed resolution

Check if $original_path is a string before calling explode().

Comments

hargobind created an issue. See original summary.

hargobind’s picture

Status: Active » Needs review
StatusFileSize
new600 bytes

Attached is a patch that checks if $original_path is NULL and returns immediately.

hargobind’s picture

Issue summary: View changes
volha_si’s picture

Faced the same error. The fix worked for me.

hargobind’s picture

Status: Needs review » Reviewed & tested by the community
_shy’s picture

Status: Reviewed & tested by the community » Closed (outdated)

D7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.

Everyone can apply the patch above (not tested by the maintainers, tested by the community) to their D7 projects.
If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.

Thanks!

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.