JSON Decoding Failure WP Migrate Plugin error [Solution]

Updated on September 6, 2018

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.

The error usually occurs when the JavaScript process that controls the migration receives an error or some other response instead of JSON for an AJAX request. This happens when a WordPress theme or a plugin that output’s error conflicting WP migrate’s migration process. The error message even suggests to set WP_DEBUG to false in wp-config.php file to prevent theme or a plugin from outputting error.

The issue here’s I did set WP_DEBUG to false in 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 DROP, RENAME and CREATE commands.

I understand that the WP Migrate plugin creates a temporary table to perform migration operations. For example something like below:

RENAME TABLE _mig_wp_commentmeta TO wp_commentmeta

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.

Was this article helpful?

Related Articles

Leave a Comment