Skip Navigation

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

Problem:
You are experiencing a lot of deprecation errors from the WPML plugin, which is causing a flood of events in your debug log file. Specifically, the error is related to the

preg_match()

function being passed a null value in the

mobile-detect.php

file.
Solution:
We recommend a workaround to address this issue. Please ensure to backup your database and website before making any changes. You need to edit the file at

wp-content/plugins/sitepress-multilingual-cms/lib/mobile-detect.php

. Around line 271, replace the existing code:

public function setUserAgent($userAgent = null){

with:

public function setUserAgent($userAgent = 'NOT NULL'){

If this solution does not resolve your issue or seems irrelevant due to updates or differences in your setup, 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 the problem persists, 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 Long Nguyen 1 year ago.

Assisted by: Long Nguyen.

Author Posts
May 21, 2024 at 7:51 am #15648365

ictA-2

Hi,

Lately we have been getting a lot of deprecation errors from the wpml plugin. This is causing a flood of events in our debug log file.

PHP Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /var/www/websales/production/wp-content/plugins/sitepress-multilingual-cms/lib/mobile-detect.php on line 562

May 22, 2024 at 7:25 am #15654304

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Our 2nd tier support needs to have the backup file to investigate the issue because we cannot replicate the issue on a minimal environment with WPML plugins and a WordPress theme.

I suggest you copy your site to a staging site and enable the minimal environment:
- Deactivate all non-WPML plugins
- Switch to a standard theme of WordPress

If the issue persists, please create a backup of your site and database then share the file in your next reply. You can use this plugin to create the backup: https://wordpress.org/plugins/duplicator/

Looking forward to your reply.
Thanks

May 23, 2024 at 1:39 am #15659983

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

This issue has been escalated to our development team and we suggest a workaround to fix this. Note: Please backup your database and website before proceeding.

- Edit the file wp-content/plugins/sitepress-multilingual-cms/lib/mobile-detect.php

- Around line 271, replace the code

public function setUserAgent($userAgent = null){

with this one

public function setUserAgent($userAgent = 'NOT NULL'){

Looking forward to your reply.
Thanks

May 23, 2024 at 7:08 am #15660603

ictA-2

Hi,

Thanks for the suggestion.
I updated the code. I will monitor for a few days to see if the issue is now solved.

Thanks for your help!

May 23, 2024 at 8:19 am #15661203

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

I'm waiting for your feedback.

Thanks.