Skip Navigation

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

Problem:
You are encountering a deprecated error and headers already sent issue on your login page when debug mode is enabled in a WPML environment. The specific error message is: 'Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/wp-includes/class-wp-user.php on line 216'. This is followed by a failure to load the page due to 'Cannot modify header information - headers already sent by ...'.
Solution:
We recommend updating your WPML to the latest version as this issue should be resolved in that update. Before updating, ensure to back up your site. If this solution does not apply because it is outdated or not relevant to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If issues persist, please open a new support ticket.

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

Last updated by Dražen Duvnjak 2 months, 3 weeks ago.

Assisted by: Dražen Duvnjak.

Author Posts
July 10, 2024 at 11:01 am #15927756

johnS-9

Background of the issue:
I am trying to view the login page whilst logged out, with debug mode enabled - On a site with WPML.

Screenshots attached of the error and the code causing the error with xdebug trace shown.

Symptoms:
Error thrown:
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/wp-includes/class-wp-user.php on line 216

Then the page does not load because: "Cannot modify header information - headers already sent by ..."

Questions:
Please change this line of code:

$username = isset( $cookie_data['username'] ) ? $cookie_data['username'] : null;

To:

$username = isset( $cookie_data['username'] ) ? $cookie_data['username'] : '';

In:
wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php:653

July 10, 2024 at 11:28 am #15927916

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

thanks, the issue has already been reported and is in our developer's queue. I have also added your report, to bump up the priority.

Kind regards,
Drazen

July 13, 2024 at 6:12 am #15946471

johnS-9

Replying so the bot doesn’t clean this up. (I’d like notifying when this is resolved, unless I can join the original issue somehow).

July 15, 2024 at 5:19 am #15951914

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

no worries, I will mark the ticket as Escalated to WPML developers team, and update you when the version with fix is released.

Kind regards,
Drazen

August 20, 2024 at 1:33 pm #16087403

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

this should be fixed with the latest WPML, please make sure to update after the backup.

Regards,
Drazen