WPML error due to missing index: Table wp_options is filled up with multiple entries of wpml_translation_services

One of our users was running WP Staging Pro alongside WPML (inc. translation management) on a couple of websites. On one, in particular, pushing the staging to live site using WP Staging Pro immediately causes the wp_options table to fill up with entries with the wp_name of ‘wpml_translation_services‘. As soon as these were deleted, no further entries were created… until the next push from staging to live.

We’ve tracked this entry down to WPML translation management.

If only WP Staging Pro or WPML translation management is installed, this entry is not created, but when both are installed and changes are pushed from staging to live, the problem reappeared on this special website.

The WPML support provided us with a solution to this issue that we want to publish here for anyone else with the same error:

It looks like the issue has happened because the indexing is missing on the wp_options table. The index of options table is very specific and crucial and every plugin or theme could create issues if it is missing.

Please try the following steps after a full site backup:

1) Log in to the Database server using PHPMyAdmin or similar tools
2) Choose the Database and run the following queries first

DELETE
FROM `wp_options`
WHERE `option_name` = 'wpml_dependencies:needs_validation';

DELETE
FROM `wp_options`
WHERE `option_name` = 'jetpack_callables_sync_checksum';

DELETE
FROM `wp_options`
WHERE `option_name` = 'gf_upgrade_lock';

DELETE
FROM `wp_options`
WHERE `option_name` = 'wpstg_license_key';

DELETE
FROM `wp_options`
WHERE `option_name` = 'wpstg_license_status';

DELETE
FROM `wp_options`
WHERE `option_name` = 'wpstg_settings';

DELETE
FROM `wp_options`
WHERE `option_name` = 'fs_accounts';

DELETE
FROM `wp_options`
WHERE `option_name` = 'jetpack_plugin_api_action_links';

DELETE
FROM `wp_options`
WHERE `option_name` = 'jpsq_sync_checkout';

DELETE
FROM `wp_options`
WHERE `option_name` = 'stats_cache';

3) Then run the following query to index the options table

ALTER TABLE `wp_options`
ADD UNIQUE `option_name` (`option_name`);

4) Create a new staging site, because may there may be a strong chance to have the same bug with the existing staging site.

5) Make changes on the new staging site and push to live site

6) Then please check you are getting multiple entries for *wpml_translation_services* or not