From d1f72a633080600fded4a40189bd18504822212c Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 18 Aug 2023 23:23:33 +0000 Subject: [PATCH] Revert the last use of `str_starts_with()` in `update-core.php`. Fixes updating WordPress from 5.7 and earlier versions. When doing the update this file runs first in the old version where the polifills may not be available. Porps: frankit. Fixes: #59145. git-svn-id: https://develop.svn.wordpress.org/trunk@56417 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/update-core.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 8d672199ee..6085b02c8f 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -1431,9 +1431,13 @@ function update_core( $from, $to ) { } else { $lang_dir = WP_CONTENT_DIR . '/languages'; } - + /* + * Note: str_starts_with() is not used here, as this file is included + * when updating from older WordPress versions, in which case + * the polyfills from wp-includes/compat.php may not be available. + */ // Check if the language directory exists first. - if ( ! @is_dir( $lang_dir ) && str_starts_with( $lang_dir, ABSPATH ) ) { + if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) { // If it's within the ABSPATH we can handle it here, otherwise they're out of luck. $wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR ); clearstatcache(); // For FTP, need to clear the stat cache.