From fb0e14e1726390fc421eb16fbe2a6cbd63826247 Mon Sep 17 00:00:00 2001
From: catch <catch56@gmail.com>
Date: Mon, 24 Oct 2022 21:29:11 +0100
Subject: [PATCH] Issue #3316971 by Mile23, andypost: Ensure run-tests.sh works
 with future PHP versions

---
 core/scripts/run-tests.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 68076ce9319b..57f48f90a929 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -545,7 +545,11 @@ function simpletest_script_init() {
   if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
     // Ensure that any and all environment variables are changed to https://.
     foreach ($_SERVER as $key => $value) {
-      $_SERVER[$key] = str_replace('http://', 'https://', $_SERVER[$key]);
+      // Some values are NULL. Non-NULL values which are falsy will not contain
+      // text to replace.
+      if ($value) {
+        $_SERVER[$key] = str_replace('http://', 'https://', $value);
+      }
     }
   }
 
-- 
GitLab