Open
Reported for: WPML Multilingual CMS 4.7.6
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
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_id
Replace 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_id
This 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_id
replace 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_id