diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index 8c7c48b3b2..770df083e7 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -170,8 +170,13 @@ class WP { list( $req_uri ) = explode( '?', $_SERVER['REQUEST_URI'] ); $self = $_SERVER['PHP_SELF']; - $home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' ); - $home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) ); + + $home_path = parse_url( home_url(), PHP_URL_PATH ); + $home_path_regex = ''; + if ( is_string( $home_path ) && '' !== $home_path ) { + $home_path = trim( $home_path, '/' ); + $home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) ); + } /* * Trim path info from the end and the leading home path from the front. @@ -180,14 +185,17 @@ class WP { */ $req_uri = str_replace( $pathinfo, '', $req_uri ); $req_uri = trim( $req_uri, '/' ); - $req_uri = preg_replace( $home_path_regex, '', $req_uri ); - $req_uri = trim( $req_uri, '/' ); - $pathinfo = trim( $pathinfo, '/' ); - $pathinfo = preg_replace( $home_path_regex, '', $pathinfo ); $pathinfo = trim( $pathinfo, '/' ); $self = trim( $self, '/' ); - $self = preg_replace( $home_path_regex, '', $self ); - $self = trim( $self, '/' ); + + if ( ! empty( $home_path_regex ) ) { + $req_uri = preg_replace( $home_path_regex, '', $req_uri ); + $req_uri = trim( $req_uri, '/' ); + $pathinfo = preg_replace( $home_path_regex, '', $pathinfo ); + $pathinfo = trim( $pathinfo, '/' ); + $self = preg_replace( $home_path_regex, '', $self ); + $self = trim( $self, '/' ); + } // The requested permalink is in $pathinfo for path info requests and // $req_uri for other requests. diff --git a/wp-includes/version.php b/wp-includes/version.php index 8dbc24083f..cf2bc62107 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51619'; +$wp_version = '5.9-alpha-51622'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.