From 4ff9e4e377b913320ebfbd8e476e48b34cfc214e Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <ben@bnf.dev>
Date: Fri, 24 Nov 2023 10:03:14 +0100
Subject: [PATCH] [TASK] Fix support for bash v3 in runTests.sh

Bash hashtables are not supported in bash v4,
so we rather use a lookup function.

Resolves: #102502
Related: #102450
Releases: main, 12.4, 11.5
Change-Id: Id5c875b78ec655e15d225914626769720bbc3a81
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81952
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
---
 Build/Scripts/runTests.sh | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh
index da27d63c84eb..2b3fffc7eb6e 100755
--- a/Build/Scripts/runTests.sh
+++ b/Build/Scripts/runTests.sh
@@ -159,6 +159,26 @@ cleanRenderedDocumentationFiles() {
     echo "done"
 }
 
+getPhpImageVersion() {
+    case ${1} in
+        7.4)
+            echo -n "2.4"
+            ;;
+        8.0)
+            echo -n "2.4"
+            ;;
+        8.1)
+            echo -n "2.7"
+            ;;
+        8.2)
+            echo -n "1.6"
+            ;;
+        8.3)
+            echo -n "1.7"
+            ;;
+    esac
+}
+
 loadHelp() {
     # Load help text into $HELP
     read -r -d '' HELP <<EOF
@@ -393,13 +413,6 @@ SUFFIX=$(echo $RANDOM)
 NETWORK="typo3-core-${SUFFIX}"
 CI_PARAMS=""
 CONTAINER_HOST="host.docker.internal"
-declare -A PHP_IMAGE_VERSIONS=(
-    ["7.4"]="2.4"
-    ["8.0"]="2.4"
-    ["8.1"]="2.7"
-    ["8.2"]="1.6"
-    ["8.3"]="1.7"
-)
 
 # Option parsing updates above default vars
 # Reset in case getopts has been used previously in the shell
@@ -438,7 +451,7 @@ while getopts ":a:b:s:c:d:i:p:e:xy:o:nhug" OPT; do
             ;;
         p)
             PHP_VERSION=${OPTARG}
-            if [[ -z "${PHP_IMAGE_VERSIONS[${PHP_VERSION}]:-}" ]]; then
+            if ! [[ ${PHP_VERSION} =~ ^(7.4|8.0|8.1|8.2|8.3)$ ]]; then
                 INVALID_OPTIONS+=("${OPTARG}")
             fi
             ;;
@@ -508,7 +521,7 @@ if ! type ${CONTAINER_BIN} >/dev/null 2>&1; then
     exit 1
 fi
 
-IMAGE_PHP="ghcr.io/typo3/core-testing-$(echo "php${PHP_VERSION}" | sed -e 's/\.//'):${PHP_IMAGE_VERSIONS[$PHP_VERSION]}"
+IMAGE_PHP="ghcr.io/typo3/core-testing-$(echo "php${PHP_VERSION}" | sed -e 's/\.//'):$(getPhpImageVersion $PHP_VERSION)"
 IMAGE_NODEJS="ghcr.io/typo3/core-testing-js:1.3"
 IMAGE_NODEJS_CHROME="ghcr.io/typo3/core-testing-js-chrome:1.3"
 IMAGE_ALPINE="docker.io/alpine:3.8"
-- 
GitLab