From b5a1f1609da4ea2d5db0606406631f574db46be0 Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Thu, 6 Aug 2026 16:41:54 +0200 Subject: [PATCH] Restore the home path fallback when realpath() fails --- src/wp-admin/includes/network.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/network.php b/src/wp-admin/includes/network.php index 15c58c65a3148..e3bf523d710f7 100644 --- a/src/wp-admin/includes/network.php +++ b/src/wp-admin/includes/network.php @@ -415,9 +415,12 @@ function network_step2( $errors = false ) { $hostname = get_clean_basedomain(); $slashed_home = trailingslashit( get_option( 'home' ) ); $base = parse_url( $slashed_home, PHP_URL_PATH ); - $document_root_fix = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) ); + $document_root = isset( $_SERVER['DOCUMENT_ROOT'] ) ? realpath( $_SERVER['DOCUMENT_ROOT'] ) : false; + $document_root_fix = $document_root ? str_replace( '\\', '/', $document_root ) : ''; $abspath_fix = str_replace( '\\', '/', ABSPATH ); - $home_path = str_starts_with( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path(); + $home_path = ( '' !== $document_root_fix && str_starts_with( $abspath_fix, $document_root_fix ) ) + ? $document_root_fix . $base + : get_home_path(); $wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix ); $rewrite_base = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';