Skip Navigation

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 9 replies, has 2 voices.

Last updated by Andrey 1 year, 7 months ago.

Assisted by: Andrey.

Author Posts
October 11, 2023 at 12:51 pm #14559591

marcH-23

Hi,

I am trying to go to the WP login page with the /wp-admin URL on my local website without already being connected. WP_DEBUG is set to true in the wp-config.php file. My WPML plugin is on 4.6.5 version and WP in 6.3.1.

I expected to see the login page without errors but instead i got this warning : Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in wp-includes/class-wp-user.php on line 211.

While traveling through the error Stack, I found that this file is problematic at line 653 : sitepress-multilingual-cms/sitepress.class.php. The variable $username is defined with an empty string on the line 650 but if username is not found in cookie datas, the $username variable is set to null. That cause error this error. Is it possible to replace this code :

$username = '';
			if ( function_exists( 'wp_parse_auth_cookie' ) ) {
				$cookie_data = wp_parse_auth_cookie();
				$username    = isset( $cookie_data['username'] ) ? $cookie_data['username'] : null;
			}

by this ?

$username = '';
			if ( function_exists( 'wp_parse_auth_cookie' ) ) {
				$cookie_data = wp_parse_auth_cookie();
				$username    = isset( $cookie_data['username'] ) ? $cookie_data['username'] : '';
			}

It fix the error for me but if i update your plugin on the next release, i probably got the same error again cause my fix will be erased. (This code is the same on the current last version of WPML plugin 4.6.6)

Thanks in advance.

Capture d’écran 2023-10-11 à 14.48.53.png
October 11, 2023 at 7:41 pm #14561777

Andrey
WPML Supporter since 06/2013

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

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

Even though the code is the same, it could be fixed in the other place of the plugin.

I encourage you to update WPML to the latest version and inform us about the results.

How to register WPML to receive automated updates:
https://wpml.org/faq/install-wpml/

October 12, 2023 at 7:38 am #14563259

marcH-23

The code on the last version have the same problem. The update did not correct the problem. It's the same error and $username on line 653 is defined to null if nothing is found in cookie datas (as in the previous version).

This error is only present since PHP 8.1.

October 12, 2023 at 8:34 am #14563901

Andrey
WPML Supporter since 06/2013

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

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

I’ll need a little more information to see what’s happening here. Do you still have this error if you temporarily deactivate all the plugins except WPML? What are the results with any default theme?

October 13, 2023 at 10:19 am #14571933

marcH-23

Yes i still have the error if i disable all plugins except :
- WPML multilingual CMS
- WPML SEO
- WPML String translations

If i test with a default theme (Twenty Twenty-Three Version: 1.2) i still have the error (with all plugin disabled except WPML).

If i disable the WPML plugins, the error disapear.

The error only occurs in offline mode when I enter the URL /wp-admin. The /wp-login.php works.

October 13, 2023 at 1:43 pm #14573825

Andrey
WPML Supporter since 06/2013

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

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

Thank you for the update.

Could you clarify "The error only occurs in offline mode"? Would it be possible for you to share the access details so I can check the error? I couldn't replicate the issue on the fresh installation.

October 13, 2023 at 2:45 pm #14574185

marcH-23

Yes :
- the offline mode is when I am not logged in as administrator
- when I want to log in, I enter the URL /wp-admin after my domain and normally the wordpress authentication form is displayed. In this specific case, the WordPress authentication form is not displayed and I have the error message indicated in my previous messages.
- i can deploy the website with the error on a staging environment. How can i share you access details so you can check the error ?

October 16, 2023 at 7:06 pm #14588311

Andrey
WPML Supporter since 06/2013

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

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

Thank you for the explanation.

I need to request temporary access (wp-admin and FTP) to your site – preferably to a test site where the problem has been replicated if possible – in order to be of better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

October 20, 2023 at 9:04 am #14622095

marcH-23

I finally can't provide you a staging environment with the error, sorry.
To reproduce the error, here are the steps :
- on a new wordpress with a default theme (twenty twenty three for example), go to /wp-admin page
- WP version is in 6.3.2
- WPML plugin is in 4.6.7
- activate error in wp-config.php file (WP_DEBUG, WP_DEBUG_LOG, WP_DEBUG_DISPLAY need to be set to true)
- PHP version is in 8.1
=> with this configuration, the /wp-admin page is broken. The deprecated error sent in my first message is displayed and the login form is not displayed.

I test a fix explained in my first message and it work but the new 4.6.7 does not have it so on the configuration listed above, I still have the error.

October 23, 2023 at 12:24 pm #14637967

Andrey
WPML Supporter since 06/2013

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

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

No problem. Thank you for your feedback. I was able to reproduce the issue using your steps and have reported it to our team. I hope it will be addressed in future releases.