Overview of the Issue
When using WPML on a site with a custom database prefix (not the default “wp_”) and 30 or more languages, you might experience a database error when visiting the translation dashboard.
This occurs due to a hard-coded database prefix in the WPML plugin code.
Workaround
This issue is fixed. Updating to the latest version solves it on your site, so you only need this workaround if you can’t update yet.
Please make sure you have a full backup of your site before proceeding.
Open:
/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/wpml/src/Infrastructure/WordPress/Component/Item/Application/Query/SearchQuery/QueryBuilder/ManyLanguagesStrategy/SearchQueryBuilder.php
Look for:
LEFT JOIN wp_icl_translations target_t
ON target_t.trid = source_t.trid
AND target_t.language_code IN ({$gluedEscapedLanguageCodes})
LEFT JOIN wp_icl_translation_status target_ts
ON target_ts.translation_id = target_t.translation_idReplace with:
LEFT JOIN {$this->queryPrepare->prefix()}icl_translations target_t
ON target_t.trid = source_t.trid
AND target_t.language_code IN ({$gluedEscapedLanguageCodes})
LEFT JOIN {$this->queryPrepare->prefix()}icl_translation_status target_ts
ON target_ts.translation_id = target_t.translation_idThis change ensures that the query uses the correct custom prefix instead of the hardcoded wp_.
Another place is in :
/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/wpml/src/Infrastructure/WordPress/Component/Item/Application/Query/SearchQuery/QueryBuilder/ManyLanguagesStrategy/SearchPopulatedTypesQueryBuilder.php
Look for:
LEFT JOIN wp_icl_translations target_t
ON target_t.trid = source_t.trid
AND target_t.language_code IN ({$gluedEscapedLanguageCodes})
LEFT JOIN wp_icl_translation_status target_ts
ON target_ts.translation_id = target_t.translation_idreplace with:
LEFT JOIN {$this->queryPrepare->prefix()}icl_translations target_t
ON target_t.trid = source_t.trid
AND target_t.language_code IN ({$gluedEscapedLanguageCodes})
LEFT JOIN {$this->queryPrepare->prefix()}icl_translation_status target_ts
ON target_ts.translation_id = target_t.translation_idStill Seeing This Issue?
If updating doesn’t fix it, ask a support question and we’ll look into it with you.
Ask a support question