Fixed litespeed purge

main
Anthony 2025-08-09 01:24:14 +08:00
parent 385cbd41b4
commit eb9a13d30b
1 changed files with 24 additions and 2 deletions

View File

@ -283,13 +283,35 @@ fi
# Purge LiteSpeed Cache (if plugin installed) # Purge LiteSpeed Cache (if plugin installed)
info "Attempting LiteSpeed Cache purge (wp litespeed-purge all)…" info "Attempting LiteSpeed Cache purge (wp litespeed-purge all)…"
PURGE_URL_HTTPS="$TARGET_URL"
PURGE_URL_HTTP="http://$HOST_ONLY"
# First attempt with HTTPS
LS_CMD=() LS_CMD=()
if [[ -n "$SUDO_CMD" ]]; then if [[ -n "$SUDO_CMD" ]]; then
# shellcheck disable=SC2206 # shellcheck disable=SC2206
LS_CMD=($SUDO_CMD) LS_CMD=($SUDO_CMD)
fi fi
LS_CMD+=("$WP_EXECUTABLE" "litespeed-purge" "all" "${WP_RUN_ARGS[@]}") LS_CMD+=("$WP_EXECUTABLE" "litespeed-purge" "all" "${WP_RUN_ARGS[@]}" "--url=$PURGE_URL_HTTPS")
"${LS_CMD[@]}" || warning "LiteSpeed purge returned non-zero exit status (plugin may be inactive)." PURGE_OUTPUT=$( "${LS_CMD[@]}" 2>&1 ) || true
printf "%s\n" "$PURGE_OUTPUT"
# If SSL verification fails, retry over HTTP
if echo "$PURGE_OUTPUT" | grep -qiE "cURL error 60|SSL certificate problem"; then
warning "LiteSpeed purge failed due to SSL verification. Retrying over HTTP…"
LS_CMD=()
if [[ -n "$SUDO_CMD" ]]; then
# shellcheck disable=SC2206
LS_CMD=($SUDO_CMD)
fi
LS_CMD+=("$WP_EXECUTABLE" "litespeed-purge" "all" "${WP_RUN_ARGS[@]}" "--url=$PURGE_URL_HTTP")
PURGE_OUTPUT=$( "${LS_CMD[@]}" 2>&1 ) || true
printf "%s\n" "$PURGE_OUTPUT"
fi
if echo "$PURGE_OUTPUT" | grep -qiE "Error|Warning"; then
warning "LiteSpeed purge may not have completed successfully."
fi
# Delete all transients recommended after domain/URL migration # Delete all transients recommended after domain/URL migration
info "Deleting all transients (wp transient delete --all)..." info "Deleting all transients (wp transient delete --all)..."