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.
Our next available supporter will start replying to tickets in about 5.05 hours from now. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 14:00 | 9:00 – 14:00 | 9:00 – 14:00 | 9:00 – 14:00 | 9:00 – 14:00 | - |
- | 19:00 – 22:00 | 19:00 – 22:00 | 19:00 – 22:00 | 19:00 – 22:00 | 19:00 – 22:00 | - |
Supporter timezone: Europe/Paris (GMT+01:00)
This topic contains 12 replies, has 4 voices.
Last updated by jamesB-36 5 years, 9 months ago.
Assisted by: Yvette.
Author | Posts |
---|---|
January 25, 2019 at 1:42 pm #3129131 | |
severinP |
One filter is adding a backslash in the upload_dir['baseurl'] You will find this filter in wp-content/plugins/sitepress-multilingual-cms/classes/url-handling/converter/filters/class-wpml-lang-domain-filters.php /** * @param array $upload_dir * * @return array */ public function upload_dir_filter_callback( $upload_dir ) { $upload_dir['url'] = $this->wpml_url_converter->convert_url( $upload_dir['url'] ); $upload_dir['baseurl'] = $this->wpml_url_converter->convert_url( $upload_dir['baseurl'] ); return $upload_dir; } It should be replaced by /** * @param array $upload_dir * * @return array */ public function upload_dir_filter_callback( $upload_dir ) { $upload_dir['url'] = $this->wpml_url_converter->convert_url( $upload_dir['url'] ); $upload_dir['baseurl'] = untrailingslashit($this->wpml_url_converter->convert_url( $upload_dir['baseurl'] )); return $upload_dir; } If you look in the wp documentation you will see that the baseurl should never have a trailingslash (and it's used a lot directly appending a slash to it) meanwhile the url does have one You can simply dump the value of $upload_dir['baseurl'] before and after modification and you'll see what I mean. Thanks |
January 28, 2019 at 9:43 am #3134742 | |
Yvette Supporter
Languages: English (English ) Spanish (Español ) Timezone: Europe/Paris (GMT+01:00) |
Hello Thanks for pointing this out to us. May I please get more information on the install configuration you have so that I can replicate this issue? Clarifications: If it was programtically, since I am not a developer, would you mind including the code you wrote to check this behaviour so I can send a test case to the development team? 2. Technical Information on you environment Thank you for your colalboration. |
January 28, 2019 at 10:53 am #3135036 | |
severinP |
Hello, It's not about environement, you will find this issue when you upload images, if you include them in a post or page you will see the link will be something like It doesn't affect how the image will be displayed that's why this issue is minor and hard to find But I does affect browser caching of the image if you also include it in the page with the correct link, the image will be loaded twice instead of only once. |
January 28, 2019 at 5:18 pm #3136885 | |
Yvette Supporter
Languages: English (English ) Spanish (Español ) Timezone: Europe/Paris (GMT+01:00) |
Hello I tried to replicate this on a fresh installation on a sandbox server. but was not successful. Here is what I did: Am I executing the correct steps to replicate the situation you are describing? |
January 31, 2019 at 3:25 pm #3148563 | |
severinP |
I forgot to mention this issue is situated in WPML_Lang_Domain_Filters class meaning that you need to have the site setup with multiple domains per language to see this issue Eg( domain1.com => english domain2.com => french ) Sorry Otherwise yes the steps you did will show you the issue There is also a minor optimisation problem in that file /** * @param string $url * * @return string */ public function siteurl_callback( $url ) { $getting_network_site_url = $this->debug_backtrace->is_function_in_call_stack( 'get_admin_url' ) && is_multisite(); if ( ! $this->debug_backtrace->is_function_in_call_stack( 'get_home_path' ) && ! $getting_network_site_url ) { $parsed_url = wpml_parse_url( $url ); $host = is_array( $parsed_url ) && isset( $parsed_url['host'] ); if ( $host && isset( $_SERVER['HTTP_HOST'] ) && $_SERVER['HTTP_HOST'] ) { $domain_from_global = $this->get_host_from_HTTP_HOST(); if ( $domain_from_global ) { $url = str_replace( $parsed_url['host'], $domain_from_global, $url ); } } } return $url; } Should be changed to that (It avoids one call to debug_backtrace) because of the associativity of the && (left to right) since this filter is used heavily, this is a huge improvement in the end /** * @param string $url * * @return string */ public function siteurl_callback( $url ) { $getting_network_site_url = is_multisite() && $this->debug_backtrace->is_function_in_call_stack( 'get_admin_url' ); if ( ! $getting_network_site_url && ! $this->debug_backtrace->is_function_in_call_stack( 'get_home_path', !is_multisite() ) ) { $parsed_url = wpml_parse_url( $url ); $host = is_array( $parsed_url ) && isset( $parsed_url['host'] ); if ( $host && isset( $_SERVER['HTTP_HOST'] ) && $_SERVER['HTTP_HOST'] ) { $domain_from_global = $this->get_host_from_HTTP_HOST(); if ( $domain_from_global ) { $url = str_replace( $parsed_url['host'], $domain_from_global, $url ); } } } return $url; } Off subject but just an idea to consider I don't know about your deployment process and maybe it will be too complicated to setup It wouldn't be open source because the repo is still private to only paying users but at least you would gain the benefice of it where your users can make improvements and having an automated test suite to make sure there is no regression |
January 31, 2019 at 5:17 pm #3149055 | |
Yvette Supporter
Languages: English (English ) Spanish (Español ) Timezone: Europe/Paris (GMT+01:00) |
Thanks for that detail - I will set that up on the test server and see if I can reproduce it. Ref the git server, we do this already for wpml-config files and page builders integration. I´ve just checked with our senior supporters and they have told me that usually bug fixes are submitted in patch format. Example git init git add . git commit -am "Initial import" - do your changes git diff > patch.txt - send us patch.txt Does that sound like something you would use? |
February 1, 2019 at 10:51 am #3151281 | |
severinP |
Yes, this works, where would I submit the patch after, in the support or is there somewhere else? |
February 1, 2019 at 1:27 pm #3151733 | |
Yvette Supporter
Languages: English (English ) Spanish (Español ) Timezone: Europe/Paris (GMT+01:00) |
Yes, in the support forum. And, btw, I was able to replicate the error - so if you want to include it with this same ticket, I can escalate the bug and the optimisation together. I am opening the private area where you can place the patch.txt |
February 8, 2019 at 10:08 am #3174321 | |
frankB-33 |
Hi, I have exactly the same issue. Is there already a fix avaible? It is quit anoying I can not publish my new languge because of all kind of errors caused by double slashes. For example, my header picture will not be displayed caused by this error. In my case the error apeared when I switched over to different domains per language. By the way, The fix of severinP worked for me as well. |
February 12, 2019 at 11:18 am #3188071 | |
severinP |
Hello, here is the patch file (PS: it's not possible to add a txt file here so I zipped the file) |
February 14, 2019 at 10:28 am #3198814 | |
Yvette Supporter
Languages: English (English ) Spanish (Español ) Timezone: Europe/Paris (GMT+01:00) |
Hi The patch file did not load so I am opening the private area again as I see it did not open before. |
January 21, 2020 at 3:11 pm #5333913 | |
frankB-33 |
Hi, This issue is still not fixed. Everytime I get a WPML update, I have to apply severinP's fix in the code. |
August 20, 2020 at 2:40 am #6834893 | |
jamesB-36 |
Yeah, still a problem. Instead of modifying the plugin, I used the upload_dir filter at a later priority to remove the extra slash. |