Added wp cache flush and transient flush

main
Anthony 2025-08-06 21:35:26 +08:00
parent c2f5c80260
commit f82d941dcc
2 changed files with 13 additions and 4 deletions

View File

@ -524,8 +524,6 @@ actions:
commands: commands:
- cd /var/www/webroot/ROOT/ - cd /var/www/webroot/ROOT/
- bash /home/litespeed/mbmanager/scripts/wp-search-replace.sh '${settings.old_url}' '${settings.new_url}' --all-tables - bash /home/litespeed/mbmanager/scripts/wp-search-replace.sh '${settings.old_url}' '${settings.new_url}' --all-tables
- /home/litespeed/bin/wp transient delete --all
- /home/litespeed/bin/wp cache flush
- return: - return:
type: info type: info
message: "Search and Replace completed successfully for '${settings.old_url}' with '${settings.new_url}' in all tables. Deleted Transients and Flushed WP Cache" message: "Search and Replace completed successfully for '${settings.old_url}' with '${settings.new_url}' in all tables. Deleted Transients and Flushed WP Cache"

View File

@ -173,9 +173,20 @@ STATUS=$?
if [[ $STATUS -eq 0 ]]; then if [[ $STATUS -eq 0 ]]; then
success "'wp search-replace' command completed successfully." success "'wp search-replace' command completed successfully."
# Optional: flush caches to ensure changes propagate
# Delete all transients recommended after domain/URL migration
info "Deleting all transients (wp transient delete --all)..."
TRANS_CMD=()
if [[ -n "$SUDO_CMD" ]]; then
# shellcheck disable=SC2206
TRANS_CMD=($SUDO_CMD)
fi
TRANS_CMD+=("$WP_EXECUTABLE" "transient" "delete" "--all" "${WP_RUN_ARGS[@]}")
"${TRANS_CMD[@]}" || warning "Transient delete command returned non-zero exit status."
# Flush object/cache to ensure changes propagate immediately
info "Flushing WordPress caches (wp cache flush)..." info "Flushing WordPress caches (wp cache flush)..."
FLUSH_CMD=( ) FLUSH_CMD=()
if [[ -n "$SUDO_CMD" ]]; then if [[ -n "$SUDO_CMD" ]]; then
# shellcheck disable=SC2206 # shellcheck disable=SC2206
FLUSH_CMD=($SUDO_CMD) FLUSH_CMD=($SUDO_CMD)