Skip Navigation

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

Problem:
Browser redirection not working as expected

Solution:
See this reply on the ticket for details: https://wpml.org/forums/topic/php-warning/page/2/#post-14288957

Relevant Documentation:

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

Last updated by Waqas Bin Hasan 8 months, 1 week ago.

Assisted by: Waqas Bin Hasan.

Author Posts
August 4, 2023 at 2:14 pm #14155415

steveK-13

Hi there,

The website is hidden link Sometimes the language switcher based on browser languages works and sometimes not. I asked Namecheap support what may be the issue, because I thinked its some kind of cache problem, and they said it's probably some kind of PHP error, copy/paste:

Also, I can see recent errors that can be related to the issue:
[03-Aug-2023 13:24:04 UTC] PHP Warning: Attempt to read property "post_content" on null in /home/linkmfev/public_html/wp-content/plugins/sitepress-multilingual-cms/inc/translation-proxy/wpml-pro-translation.class.php on line 420
[03-Aug-2023 13:24:04 UTC] PHP Warning: Attempt to read property "post_type" on null in /home/linkmfev/public_html/wp-content/plugins/sitepress-multilingual-cms/inc/translation-proxy/wpml-pro-translation.class.php on line 421

What may be the problem?

August 7, 2023 at 10:05 am #14162791

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hello Steve,

Thank you for contacting the support.

Can you please explain about "language switcher based on browser languages works and sometimes not"? I mean do you get any error page, language isn't switched or ...?

Secondly, I 'll advise you to fix “WP Memory Limit” to at least 128MB while 256MB is recommended. See https://wpml.org/home/minimum-requirements/ for detailed information. You can set this in your wp-config.php file by adding following code:

define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

Remember to add these lines before the line where it says:
/* That's all, stop editing! Happy publishing. */

IMPORTANT: Take full backup of your website and database before continuing further.

Once this is fixed, open any page or post in default language, make a small change like a dot, save and update translations. Then clear all caches and check for the issue, if it still can be reproduced.

During this practice, I'll recommend enable debugging on your site. See https://wpml.org/documentation/support/debugging-wpml/ for details.

I'll also recommend checking with WPML plugins only that if the issue or the said warnings/errors can be reproduced in debug log.

Please let me know.

Regards.

August 7, 2023 at 4:32 pm #14165457

steveK-13

Thank you for your reply.

I meant that: if I am checking the automatical language switcher based on browser language, then for me Edge/Mozilla switching languages automatically on PCs, but not switching languages if Chrome PC (tried in incognito) and mobile wont switch languages at all.
I tried some other devices also and there works, but its not working for me and the website owner also not working.

I cleared the cache in WPML and the WP Memory Limit changed also + I dont use any caching plugins.

August 8, 2023 at 10:03 am #14168195

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the updates.

So the problem is with Chrome on PC and Mobile. I can check that, if you can please write me some steps and URLs. For example, which locations to check from and what to expect. I can use a VPN to try these things and can assess about the problem.

August 8, 2023 at 12:23 pm #14169183

steveK-13

Yes, please check. If, example, opening the website with estonian language (Eesti) with Estonia IP, then it's still in English.

August 8, 2023 at 1:15 pm #14169481

steveK-13

One user also tested the system in Finland. His browser language is Finland, but it was opening with estonian language.

August 9, 2023 at 8:24 am #14173377

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the details.

I wasn't able to check with Estonian location but my VPN allowed me to connect via Finland.

When I accessed the site at hidden link, it loaded in English but then switched to hidden link automatically and showed the site in Finish language (see attached). I used Chrome and changed browser language to "Finish - Suomi", then restarted the browser and checked in Incognito mode.

May I ask for admin access to your website to check the issue in detail? You can create a separate admin user for this purpose, which can be deleted afterwards.

Remember to take full backup of your website and database before proceeding. However, a staging/test site is highly recommended, because I may need to try some changes/fixes on the site (including plugins & themes deactivation), which may cause conflicts with the live site otherwise.

Please confirm it in your next reply or let me know if you do not agree with the mentioned.

I've set your next reply as private to share this information safely.

IMPORTANT: If you don't see the section for providing access information, do not write in the message box or the information may appear as public.

See https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/ for details on privacy and security.

finland.jpg
August 9, 2023 at 2:07 pm #14176511

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the access. I'll check this soon and 'll update you accordingly (tomorrow at earliest).

August 10, 2023 at 7:11 am #14179645

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation.

I checked the site again using different locations and mostly seems to work fine.

WP Admin is also clean and set properly.

At the moment I can only suggest the followings:

IMPORTANT: Take full backup of your website and database beforehand.

- Update WPML plugins to the latest versions, clear caches and recheck.
- Create a staging/dev site by cloning the same site, so we can then further test by activating/deactivating plugins and themes. So we can see if an other plugin or theme having any compatibility issue (particular to the said problem).
- Since you also mentioned about some PHP Warnings in the beginning, we 'll also need to enable the debugging during this practice to catch and observe errors. Apparently the said one don't seem to be the reason but in the context of previous point, we 'll need to investigate in more detail.

Please let me know. And if you prepare a staging site and want to share the credentials, I've set your next reply as private.

August 14, 2023 at 8:57 pm #14199931

steveK-13

Thank you for your reply.

I updated the WPML, cleared cache, but it still wont work with Chrome PC and mobile also for me. Yes, some devices are working with (changing language), but many device wont work.

P.S. I just checked and if, example, Germany IP, then wont work with Edge PC also ... goes to Eesti language.

P.P.S. Copy/paste:
Advanced Translation Editor
Error Logs (49)

August 15, 2023 at 7:14 am #14201507

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for trying, I just checked ATE Error Logs in your site (WPML -> Support -> Advanced Translation Editor -> Error Logs) and the latest error was on June 26th. This means there's no new error and usually these error do not relate the said problem.

However, can you create a staging or dev site of the same and reproduce the same issue? If yes, then please provide the access to the staging site so we can debug and investigate starting with minimal possible plugins.

I've set your next reply as private to provide access to the staging site.

On the other hand, do you also see any error in debug.log or the same ones recently (as mentioned in your first message)?

August 17, 2023 at 1:10 pm #14246533

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the details.

That brief moment of switching between languages, I need to confirm with the team. But I think that's expected, like as soon as browser provides the location, the underlying script takes action.

Sometimes if it is working fine and sometimes not, this is clearly to do with caching, either on-site, hosting service and/or user's browser.

However, is this ok for you, if I create an All-in-One-Migration or Duplicator package, download and try in another environment? Or if you can create one and share?

This way I'll be able to figure out the problem more efficiently. Please see https://wpml.org/faq/provide-supporters-copy-site/ for more details.

I've set your next reply as private to share this information safely.

August 18, 2023 at 7:34 am #14250269

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the package and the updates. I've downloaded the package.

I'll soon try to install it and check on my local. If there's any problem I'll try to create one from the site.

I'll update you accordingly.

For that country/IP stuff, since you mentioned about "language switcher based on browser languages works", "automatical language switcher based on browser language", "estonian language (Eesti) with Estonia IP" and "tested the system in Finland", this means there are some factors involved like:

- browser language (which can be tested locally without changing IP or Location)
- location (which can only be tested by either changing physically or mimicking it, i.e. VPN or dev tools)

I tested both ways to reproduce the issue, to confirm if WPML's browser language somehow not-only-relying on browser language or taking user location into account as well.

I agree with you that it should consider browser language only, because the user can be located anywhere. I'll check in detail.

August 18, 2023 at 12:11 pm #14252339

steveK-13

Ok, thank you, let me know if there's any news.

August 21, 2023 at 5:27 am #14259657

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation.

I just wanted to update you that I am still working on it and trying to reproduce the problem on my local. I'll keep you posted.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.