From 436577878c51f91e7a9ed1adff87fb22321b712a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 Jan 2026 11:16:15 +0000 Subject: [PATCH 1/2] Initial plan From 51032dabaef48446b58dbd2a42af0b469a36f542 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 20 Jan 2026 11:19:54 +0000 Subject: [PATCH 2/2] Fix network failure handling in check_for_updates function - Modified download() to return error codes from curl/wget - Updated check_for_updates() to check download() return value - Added validation for empty downloaded files using -s flag - Improved error messaging to distinguish between network failures and empty files Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- templates/install-wp-tests.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/templates/install-wp-tests.sh b/templates/install-wp-tests.sh index 01260d55..b153ed04 100644 --- a/templates/install-wp-tests.sh +++ b/templates/install-wp-tests.sh @@ -30,9 +30,11 @@ WP_CORE_FILE="$WP_CORE_DIR"/wp-settings.php download() { if [ `which curl` ]; then - curl -L -s "$1" > "$2"; + curl -L -s "$1" > "$2" + return $? elif [ `which wget` ]; then wget -nv -O "$2" "$1" + return $? else echo -e "${RED}Error: Neither curl nor wget is installed.${RESET}" exit 1 @@ -43,10 +45,14 @@ check_for_updates() { local remote_url="https://raw.githubusercontent.com/wp-cli/scaffold-command/main/templates/install-wp-tests.sh" local tmp_script="$TMPDIR/install-wp-tests.sh.latest" - download "$remote_url" "$tmp_script" + if ! download "$remote_url" "$tmp_script"; then + echo -e "${YELLOW}Warning: Failed to download the latest version of the script for update check.${RESET}" + return + fi - if [ ! -f "$tmp_script" ]; then - echo -e "${YELLOW}Warning: Could not download the latest version of the script for update check.${RESET}" + if [ ! -f "$tmp_script" ] || [ ! -s "$tmp_script" ]; then + echo -e "${YELLOW}Warning: Downloaded script is missing or empty, cannot check for updates.${RESET}" + rm -f "$tmp_script" return fi