From 739bc58d13c2836c2c960a02352b53ea0b2c0102 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 8 Aug 2019 20:19:48 +0000 Subject: [PATCH] REST API: In `get_rest_url()`, check if `$_SERVER['SERVER_NAME']` is set to avoid a PHP warning in CLI context. Props paulschreiber. Fixes #47854. git-svn-id: https://develop.svn.wordpress.org/trunk@45771 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/rest-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php index 7602dd7405..5ec557547c 100644 --- a/src/wp-includes/rest-api.php +++ b/src/wp-includes/rest-api.php @@ -373,7 +373,7 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) { $url = add_query_arg( 'rest_route', $path, $url ); } - if ( is_ssl() ) { + if ( is_ssl() && isset( $_SERVER['SERVER_NAME'] ) ) { // If the current host is the same as the REST URL host, force the REST URL scheme to HTTPS. if ( $_SERVER['SERVER_NAME'] === parse_url( get_home_url( $blog_id ), PHP_URL_HOST ) ) { $url = set_url_scheme( $url, 'https' );