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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 8:00 – 15:00 | 8:00 – 15:00 | 8:00 – 15:00 | 8:00 – 15:00 | 8:00 – 15:00 | - |
- | 16:00 – 17:00 | 16:00 – 17:00 | 16:00 – 17:00 | 16:00 – 17:00 | 16:00 – 17:00 | - |
Supporter timezone: Europe/Rome (GMT+02:00)
Tagged: Bug
This topic contains 8 replies, has 0 voices.
Last updated by Alejandro 1 day, 17 hours ago.
Assisted by: Alejandro.
Author | Posts |
---|---|
June 2, 2025 at 10:16 pm #17099627 | |
diogoC-6 |
Background of the issue: However, when the parameter value is a JSON-encoded object, a critical WordPress error occurs. Original URL (before switching language): After switching language (WPML): Symptoms: Questions: |
June 3, 2025 at 3:23 pm #17103054 | |
Alejandro WPML Supporter since 02/2018
Languages: English (English ) Spanish (Español ) Italian (Italiano ) Timezone: Europe/Rome (GMT+02:00) |
Hello, Can you please share the code that is used to create such JSON and how do you add it as a parameter to the URL? because what i see at first sight is that the brackets exist in the portuguese version but the original one has it encoded, that might be part of the problem here but WPML doesn't really encodes or decodes the URL so there must be something else in between that might fail when you switch from one language to another. Thanks in advance for the reply. |
June 3, 2025 at 5:36 pm #17103617 | |
diogoC-6 |
Acctually that param is used by other plugin, Jet Engine search, however i can still see the error happenning if i create a custom param such "mycustomdata". The equivalent url generate for both are different. See below: Original url: New url after change the language: If you decode both params you get: Original param: New param after changing the language: The plugin instead of keeping the data as it was before, it escapes and this causes the error. Again, this params is not used at any place at all. I just created it to test and the wpml plugin does this. |
June 4, 2025 at 8:45 am #17105330 | |
Alejandro WPML Supporter since 02/2018
Languages: English (English ) Spanish (Español ) Italian (Italiano ) Timezone: Europe/Rome (GMT+02:00) |
I ran a test and could verify that the results are a bit weird. In my case it was that it seems to double encode the content so it ends up being incorrect, so it's different than your example but it's enough to ask our devs to verify given that we can recreate the problem from scratch. I have sent it to them and I'll be waiting on their updates. I'll keep you informed. Regards. |
June 4, 2025 at 1:58 pm #17106883 | |
diogoC-6 |
Okay, thanks in advance! |
June 5, 2025 at 7:23 am #17108796 | |
Alejandro WPML Supporter since 02/2018
Languages: English (English ) Spanish (Español ) Italian (Italiano ) Timezone: Europe/Rome (GMT+02:00) |
I'm changing the status of the ticket to avoid it from getting closed. I hope t be getting back to you later today with a proper answer. Regards, |
June 13, 2025 at 7:23 am #17131933 | |
Alejandro WPML Supporter since 02/2018
Languages: English (English ) Spanish (Español ) Italian (Italiano ) Timezone: Europe/Rome (GMT+02:00) |
Hello, We found a solution for you, but we'd need you to test it with the current plugin to see if it works for you. 1) Please edit the following file: wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php 2) Locate the following code section (should be from line 3051): if ( $parameters_copied ) { foreach ( $_GET as $k => $v ) { if ( in_array( $k, $parameters_copied, true ) ) { $gets_passed[ $k ] = $v; } } } 3) Update the $gets_passed line like so: $gets_passed[ $k ] = urlencode( wp_unslash($v) ); // wpmlsupp-12852 4) Save the changes Try it out and let me know how it goes. |
June 20, 2025 at 3:03 pm #17154740 | |
diogoC-6 |
Hello, Thank you for your response and for providing a possible solution. Unfortunately, this change does not solve the problem in my case. However, I did notice a consistent pattern that might help narrow down the root cause(Also, i've tried it with other params not used by any plugin so its not related to the plugin in this case). When the parameter contains double quotes ("), the browser already encodes them, escaping the quote with a backslash (\). This is the standard URL encoding behavior. But this escaping seems to be the source of the issue: If I pass a simple JS object like { custom: 1 } (no quotes around the key), everything works fine and the URL remains consistent after switching languages. However, if the object uses quotes around the key or value, like { "hello": "world" }, the problem appears. The URL gets extra escaping (with additional backslashes), and the parameter is broken after changing the language. It seems that somewhere else in the code (not just in the sitepress.class.php section you've shown), an additional escaping is applied, especially when the parameter already contains backslashes from the initial browser encoding. Removing just the backslashes here is not enough, since another part of the codebase appears to re-add or double-escape them. To summarize: The issue happens specifically when the parameter contains double quotes (") and they are already escaped by the browser in the URL. Parameters without quotes or with simple values do not trigger this bug. The ideal solution would be to identify where in the process the extra escaping or double encoding is being added, and remove or bypass it only for these cases. If you need more technical details or examples, I'm happy to provide them. Thank you for your support! |
June 23, 2025 at 9:34 am #17159033 | |
Alejandro WPML Supporter since 02/2018
Languages: English (English ) Spanish (Español ) Italian (Italiano ) Timezone: Europe/Rome (GMT+02:00) |
Hm, ok sto parlando con i nostri Dev per vedere se riusciamo a capire come risolvere quel problema. Ti farò sapere appena avrò altre news. |