Skip to content

Commit fad50fc

Browse files
committed
Fix DB connection args and version escaping in install-wp-tests.sh
- Build the host/port/socket options as a Bash array. Quoting "$EXTRA" right after --password glued them into the password argument, so every MySQL connection with a DB host failed (the CI failures). - Use parameter expansion for VERSION_ESCAPED. Switching from backticks to $() changed the sed result from 6\.9 to 6\\.9, breaking the minor version lookup. - Keep using the release branch for RC versions; the branch is created at RC1, so only beta versions need to fall back to trunk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWTd5pwpi2xQfDA6mUYkkx
1 parent 4d0eed0 commit fad50fc

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

‎templates/install-wp-tests.sh‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,14 @@ if [ "${WP_INSTALL_TESTS_SKIP_UPDATE_CHECK:-false}" != "true" ]; then
8282
check_for_updates
8383
fi
8484

85-
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then
86-
# Beta/RC versions — the stable branch (e.g. 7.1) does not exist yet on
87-
# GitHub, so fall back to trunk for the test suite. WordPress core itself
88-
# is still downloaded from wordpress.org which hosts beta archives.
85+
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-beta[0-9]+$ ]]; then
86+
# Beta versions — the stable branch (e.g. 7.1) is only created at RC1, so
87+
# use trunk for the test suite. WordPress core itself is still downloaded
88+
# from wordpress.org, which hosts beta archives.
8989
WP_TESTS_TAG="trunk"
90+
elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-RC[0-9]+$ ]]; then
91+
WP_BRANCH=${WP_VERSION%\-*}
92+
WP_TESTS_TAG="branches/$WP_BRANCH"
9093
elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
9194
WP_TESTS_TAG="branches/$WP_VERSION"
9295
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
@@ -142,7 +145,7 @@ install_wp() {
142145
else
143146
# otherwise, scan the releases and get the most up to date minor version of the major release
144147
local VERSION_ESCAPED
145-
VERSION_ESCAPED=$(echo "$WP_VERSION" | sed 's/\./\\\\./g')
148+
VERSION_ESCAPED=${WP_VERSION//./\\.}
146149
LATEST_VERSION=$(grep -o '"version":"'"$VERSION_ESCAPED"'[^"]*' "$TMPDIR"/wp-latest.json | sed 's/"version":"//' | head -1)
147150
fi
148151
if [[ -z "$LATEST_VERSION" ]]; then
@@ -253,9 +256,9 @@ recreate_db() {
253256
then
254257
echo -e "${CYAN}Recreating the database ($DB_NAME)...${RESET}"
255258
if command -v mariadb-admin > /dev/null 2>&1; then
256-
mariadb-admin drop "$DB_NAME" -f --user="$DB_USER" --password="$DB_PASS""$EXTRA"
259+
mariadb-admin drop "$DB_NAME" -f --user="$DB_USER" --password="$DB_PASS" "${EXTRA[@]}"
257260
else
258-
mysqladmin drop "$DB_NAME" -f --user="$DB_USER" --password="$DB_PASS""$EXTRA"
261+
mysqladmin drop "$DB_NAME" -f --user="$DB_USER" --password="$DB_PASS" "${EXTRA[@]}"
259262
fi
260263
create_db
261264
echo -e "${GREEN}Database ($DB_NAME) recreated.${RESET}"
@@ -267,9 +270,9 @@ recreate_db() {
267270

268271
create_db() {
269272
if command -v mariadb-admin > /dev/null 2>&1; then
270-
mariadb-admin create "$DB_NAME" --user="$DB_USER" --password="$DB_PASS""$EXTRA"
273+
mariadb-admin create "$DB_NAME" --user="$DB_USER" --password="$DB_PASS" "${EXTRA[@]}"
271274
else
272-
mysqladmin create "$DB_NAME" --user="$DB_USER" --password="$DB_PASS""$EXTRA"
275+
mysqladmin create "$DB_NAME" --user="$DB_USER" --password="$DB_PASS" "${EXTRA[@]}"
273276
fi
274277
}
275278

@@ -285,15 +288,15 @@ install_db() {
285288
read -ra PARTS <<< "${DB_HOST//:/ }"
286289
local DB_HOSTNAME=${PARTS[0]};
287290
local DB_SOCK_OR_PORT=${PARTS[1]};
288-
local EXTRA=""
291+
local EXTRA=()
289292

290293
if [ -n "$DB_HOSTNAME" ] ; then
291294
if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]]; then
292-
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
295+
EXTRA=(--host="$DB_HOSTNAME" --port="$DB_SOCK_OR_PORT" --protocol=tcp)
293296
elif [ -n "$DB_SOCK_OR_PORT" ] ; then
294-
EXTRA=" --socket=$DB_SOCK_OR_PORT"
297+
EXTRA=(--socket="$DB_SOCK_OR_PORT")
295298
elif [ -n "$DB_HOSTNAME" ] ; then
296-
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
299+
EXTRA=(--host="$DB_HOSTNAME" --protocol=tcp)
297300
fi
298301
fi
299302

@@ -303,7 +306,7 @@ install_db() {
303306
else
304307
local DB_CLIENT='mysql'
305308
fi
306-
if $DB_CLIENT --user="$DB_USER" --password="$DB_PASS""$EXTRA" --execute='show databases;' | grep -q "^$DB_NAME$";
309+
if $DB_CLIENT --user="$DB_USER" --password="$DB_PASS" "${EXTRA[@]}" --execute='show databases;' | grep -q "^$DB_NAME$";
307310
then
308311
echo -e "${YELLOW}Reinstalling will delete the existing test database ($DB_NAME)${RESET}"
309312
read -r -p 'Are you sure you want to proceed? [y/N]: ' DELETE_EXISTING_DB

0 commit comments

Comments
 (0)