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
Comment #2
hargobindAttached is a patch that checks if
$original_pathis NULL and returns immediately.Comment #3
hargobindComment #4
volha_si commentedFaced the same error. The fix worked for me.
Comment #5
hargobindComment #6
_shyD7 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!