Skip to content Skip to sidebar

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.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Andrey 1 year, 5 months ago.

Assisted by: Andrey.

Author Posts
September 10, 2024 at 7:06 pm #16163141

jacobS-21

Background of the issue:
I am trying to: After updating the following plugins I get a critical error when trying to switch languages on the site:
- SitePress Multilingual CMS from 4.6.10 to 4.6.13
- WPML String Translation from 3.2.11 to 3.2.14
- Gravity Forms Multilingual from 1.7.2 to 1.8.2
- Advanced Custom Fields Multilingual from 2.0.5 to 2.1.4.2
- Advanced Custom Fields PRO from 6.2.9 to 6.3.6
- Yoast SEO from 22.5 to 23.4

Link to a page where the issue can be seen:

To resolve this, I changed line 37 in sitepress-multilingual-cms/classes/wp-core-hooks/post/class-wpml-remove-pages-not-in-current-language.php from:

if ( 'all' !== $current_language && 0 !== count( $posts ) ) {

to:

if ( is_countable( $posts ) && 'all' !== $current_language && 0 !== count( $posts ) ) {

Symptoms:
PHP Fatal Error in sitepress-multilingual-cms/classes/wp-core-hooks/post/class-wpml-remove-pages-not-in-current-language.php:37

I expected to see: I expect to see the translated version of the page.

Instead, I got: In debug.log I get the following when I try to switch languages on my site:

PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /app/wordpress/wp-content/plugins/sitepress-multilingual-cms/classes/wp-core-hooks/post/class-wpml-remove-pages-not-in-current-language.php:37

Questions:
Why am I getting a PHP Fatal Error after updating the plugins?
Is my solution to change line 37 in sitepress-multilingual-cms/classes/wp-core-hooks/post/class-wpml-remove-pages-not-in-current-language.php correct?

September 10, 2024 at 7:39 pm #16163449

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kyiv (GMT+02:00)

Thank you for contacting WPML support.

I haven't seen anything similar before. Have you tried to download fresh copies of the plugins and reupload them?

What are the results if you temporarily turn off all the plugins except WPML?

You also need to update your WordPress to the latest version.

Please remember to backup your database before you proceed.