Skip to content

Commit 48e6c18

Browse files
kraftbjmatticbot
authored andcommitted
[Super Cache] Fix str_starts_with() null deprecation in get_current_url_supercache_dir (#47645)
Co-authored-by: Brandon Kraft <public@brandonkraft.com> Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/24094045575 Upstream-Ref: Automattic/jetpack@234d523
1 parent f574511 commit 48e6c18

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This is an alpha version! The changes listed here are not final.
2020
### Fixed
2121
- Ensure proper flags are used with `json_encode()`.
2222
- Fix TS errors detected by tsgo.
23+
- Fix `str_starts_with()` PHP 8.1+ deprecation when `$wp_cache_home_path` is null in `get_current_url_supercache_dir()`.
2324

2425
## [3.0.3] - 2025-11-11
2526
### Added

wp-cache-phase2.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,9 +853,10 @@ function get_current_url_supercache_dir( $post_id = 0 ) {
853853
$uri = '';
854854
}
855855
} else {
856-
$uri = str_replace( $site_url, '', $permalink );
857-
if ( ! str_starts_with( $uri, $wp_cache_home_path ) ) {
858-
$uri = rtrim( $wp_cache_home_path, '/' ) . $uri;
856+
$uri = str_replace( $site_url, '', $permalink );
857+
$home_path = $wp_cache_home_path ?? '';
858+
if ( $home_path !== '' && ! str_starts_with( $uri, $home_path ) ) {
859+
$uri = rtrim( $home_path, '/' ) . $uri;
859860
}
860861
}
861862
} else {

0 commit comments

Comments
 (0)