From 4ebd0203536a9266d5d3ff604d3151302087a6b8 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Tue, 29 Jul 2025 22:40:40 -0600 Subject: [PATCH] Enhance domain replacement process in wp-import.php with error handling and informative output --- .gitignore | 2 ++ wp-import.php | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d48c759 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +.vscode \ No newline at end of file diff --git a/wp-import.php b/wp-import.php index 2e27ce2..9c8a6f3 100644 --- a/wp-import.php +++ b/wp-import.php @@ -14,7 +14,19 @@ echo shell_exec( 'wp db import ./wp-content/mysql.sql' ); $domain = shell_exec( 'wp option get siteurl' ); $search_replace = trim( $domain ) . ' ' . trim( $staging_domain ); -echo shell_exec( "wp search-replace $search_replace --all-tables" ); + +// Replace the domain in the database. +echo "--------------------------------"; +echo "Performing search and replace:"; +echo "wp search-replace $search_replace --all-tables"; +echo "--------------------------------"; + +try { + echo shell_exec( "wp search-replace $search_replace --all-tables" ); +} catch ( Exception $e ) { + echo "Error: " . $e->getMessage(); + exit( 1 ); +} rmdir( './wp-content/plugins/post-smtp' ); rmdir( './wp-content/plugins/wordfence' );