From 21282383111f32fab6cc70b9e6c287d45ff253ff Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Fri, 12 Nov 2021 01:10:01 +0000 Subject: [PATCH] Bootstrap/Load: Check `$_SERVER['SCRIPT_NAME']` exists before passing to `strpos()` in `wp_fix_server_vars()`. If `SCRIPT_NAME'` does not exist (which can happen in cron jobs), the following happens: * PHP 8.1+: * `Warning: Undefined array key "SCRIPT_NAME"` * `Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated` * PHP 8.0: `Warning: Undefined array key "SCRIPT_NAME"` * PHP 5.6-7.4: No warning or notice This commit checks if the key exists before passing it to `strpos()`. This resolves the warning, notice, and future error. Follow-up to [3034], [3069], [12732]. Props audrasjb, costdev, hellofromTonya, karpstrucking, mcjambi, sergeybiryukov. Fixes #54142. Built from https://develop.svn.wordpress.org/trunk@52144 git-svn-id: http://core.svn.wordpress.org/trunk@51736 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/load.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/load.php b/wp-includes/load.php index d2e7f47c4f..60ce480656 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -76,7 +76,7 @@ function wp_fix_server_vars() { } // Fix for Dreamhost and other PHP as CGI hosts. - if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) { + if ( isset( $_SERVER['SCRIPT_NAME'] ) && ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) ) { unset( $_SERVER['PATH_INFO'] ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index cf7785edb7..b8cc827424 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-52143'; +$wp_version = '5.9-alpha-52144'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.