I’m a big fan of WP Migrate plugin for WordPress and that’s reason I use this plugin for migrating my client websites. However, the plugin failed in one of my client website while using find and replace feature. Well, the error was related to “JSON Decoding Failure”. Here’s the complete error message.
JSON Decoding Failure — Our AJAX request was expecting JSON but we received something else. Often this is caused by your theme and/or plugins spitting out PHP errors. If you can edit the theme or plugins causing the errors, you should be able to fix them up, but if not, you can set WP_DEBUG to false in wp-config.php to disable errors from showing up.
wp-config.php file to prevent theme or a plugin from outputting error.
The issue here’s I did set
wp-config.php file, but still the error occurred while invoking migration operation.
Note: If your WordPress site is hosted on a shared hosting that does not allow client’s to turn off PHP errors, then you might have to use the below code.
ini_set('log_errors','On'); ini_set('display_errors','Off'); ini_set('error_reporting', E_ALL ); define('WP_DEBUG', false); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false);
However, turning off PHP errors didn’t fix the issue. Finally I could find the issue and it was because of the database user not having enough privileges to execute
I understand that the WP Migrate plugin creates a temporary table to perform migration operations. For example something like below:
So the WordPress database user should have privilege to execute CREATE/DROP/RENAME commands for the plugin to work. Well, that’s exactly the problem on my client website and the plugin worked fine after providing necessary privileges.
Hope it helps someone in need.
I love bugs and I love fixing them!