 Pedro Paulo
|
Hi,
There seems to be a severe bug with 404 pages. Consider this situation. The user goes to www.example.com. WPML uses the clues provided by the browser to autodetect a language, say, Brazilian Portuguese. It then writes "pt-br" to the _icl_visitor_lang cookie. Then the user heads over to www.example.com/nonexistant, and gets a 404 page. This 404 page is not localizable as it's part of the theme, but that's okay. The problem is that going to the 404 page also resets the language to the default language (English, in my specific case), and even writes that to the cookie! Now when the user clicks a link or heads over to www.example.com later on, he or she will see the page in the wrong language (English instead of Brazilian Portuguese).
For some reason, for 404.php, in the conditional in line 591 in sitepress.class.php, $this->get_current_language() returns a value that is different from the value in the cookie if a different language was automatically detected and stored in the cookie. This is probably the cause of the problem.
I didn't investigate further. I worked around by adding && !is_404() to the if in line 573, meaning we always respect the value set in the cookie. Doing this, I now get redirected to the home page when I go to 404.php in Brazilian Portuguese, and only get the 404 page for the default language (English).
Please let me know if this description is a bit cumbersome. I can try to write down some step-by-step instructions to reproduce the problem, if needed.
Looking forward to your consideration.
Regards,
|
 Harshad
|
Pedro,
Yes it would be great, if you could write down some step-by-step instructions to reproduce the problem.
I will further investigate on the problem.
|
 Pedro Paulo
|
Hi, here it goes:
1. Create a website with two languages, say, German and English, defaulting to English. Populate at least the home pages.
2. In a new browser window, not logged into WP, visit the home page. Suppose WPML detects that your browser asked for English content, so it selects English and saves the WPML cookie.
3. Once the home page is loaded, switch to German. This will, in turn, overwrite the WPML cookie and reload the page (perhaps adding ?lang=de to the URL).
4. Go to a non-existing page by editing the URL in your browser's address bar. You should see 404.php.
5. Close the browser, reopen it, and go to the home page without specifying a lang GET argument. You would expect that the language that was saved to the cookie in step 3 (German) will be selected, but you're back to the default language. This happens because the 404 page overwrites the WPML cookie with the default language (English, in this case).
Regards,
|
 Harshad
|
Pedro,
Thanks for providing the steps, I will try out reproducing the same on my side and let you know my findings.
|