Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:

There is a PHP error happening on the website;

PHP message: PHP Fatal error: Uncaught InvalidArgumentException: Argument $language_code must be a non empty string

Solution:

Make sure that you finish the installation process by following all the setup processes shown in the prompt.

If you do not see the prompt go to WordPress Dashboard > WPML > Translation Management.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Christopher Amirian 1 year, 3 months ago.

Assisted by: Christopher Amirian.

Author Posts
November 3, 2023 at 3:01 pm #14726757

zakW

WMPL is triggering a FATAL error on our multisite install.

hidden link

To replicate go to this subsite:
hidden link

We have taken the following steps to try and fix the issue:
- Clear the cache in WPML
- Remove ghost entries from the translation tables
- Fix element_type collation
- Set language information
- Fix WPML tables collation
- Assign translation status to duplicated content
- Synchronize local job ids with ATE jobs
- Fix terms count
- Fix post-type assignment
- Cleanup and optimize string tables

The error received is:
===================================================
PHP message: PHP Fatal error: Uncaught InvalidArgumentException: Argument $language_code must be a non empty string. in ............s/language-switcher/class-wpml-ls-settings.php(407): WPML_LS_Settings->{closure}()\n#3 /home/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-render.php(144)
===================================================

November 5, 2023 at 1:45 pm #14733099

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

This is either an indication of the usage of older version of WPML or WPML addons or a corrupt database entries.

For the first one please do as follows:

- IMPORTANT STEP! Create a backup of your website. Or better approach will be to test this on a copy/staging version of the website to avoid any disruption of a live website.
- Go to "WordPress Dashboard > Plugins > Add new > Commercial (tab)".
- Click the "Check for Updates" button.
- Update WPML and its addons there.

For more information:
https://wpml.org/faq/install-wpml/#automated-updates

For the second one please do as follows:

- IMPORTANT STEP! Create a backup of your website. Or better approach will be to test this on a copy/staging version of the website to avoid any disruption of a live website.
- Go to the database of your website and perform the SQL commands below:

DELETE FROM `wp_postmeta` WHERE post_id in (select element_id from wp_icl_translations where language_code = "")
Delete from wp_posts where id in (select element_id from wp_icl_translations where language_code = "")
DELETE FROM `wp_icl_translations` WHERE `language_code` = ""

The step above e is a delicate matter and we do not advice to do it on a live website. Please do it on a copy of the website first to make sure it works.

Thanks.

November 6, 2023 at 8:52 am #14735667

zakW

Hi Christopher,

Thanks for your help with this however we can't run those SQL command now because we already managed to fix it.

We noticed that one of the subsite in the multisite instance got stuck back on the WPML onboarding process - I suspect this may be due to some corrupt database entries.

Following through the onboarding process, it did prompt us to select a default language which fixed the issue for our end.