• Resolved buggiesmalls

    (@buggiesmalls)


    Hi,

    I think there’s a bug in class-wcml-attributes.php. If you check the method filter_attribute_name here, the current language is switched based on $sanitize_in_origin here and switched back to the original language here.

    In order for the language to be changed, only $sanitize_in_origin needs to be true, but for it to be changed back to the original language, $return_sanitized has to be true as well. This isn’t always the case and in my case this causes mixed translation content on the page since it doesn’t “clean up” the language switch properly.

    My case is fixed by changing the return part (starting here) to this:

    
    ...
    
    if ( $return_sanitized ) {
        $attribute_name = sanitize_title( $attribute_name );
    }
    
    if ( $sanitize_in_origin ) {
        $this->sitepress->switch_lang( $current_language );
    }
    
    return $attribute_name;
    

    This reverts the language switch based on the same criteria it’s initially switched.

    Would be great if you could check if this is valid, and if yes include it in a future release.

    Thanks!

    WooCommerce: 4.3.1
    WooCommerce Multilingual: 4.10.1
    WPML Multilingual CMS: 4.3.18
    WPML String Translation: 3.0.13

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,
    Thanks for your contribution.

    I’ll create a ticket in our queue. Can you please also provide steps where we can see an issue in action?

    Regards,

    Thread Starter buggiesmalls

    (@buggiesmalls)

    Hi,

    thanks for taking the time. I just set up a local WP site and tried to reproduce it, which I did:

    – I created a simple WP site with the plugins I listed in my post (WP 5.4.2).
    – I added a product with attributes and set up WPML, with English as the initial default language and German as a second language.
    – I translated the product with all attributes/categories/…

    The product detail page shows the same behaviour that I reported earlier:

    The English page: https://i.imgur.com/EPSyHZv.png
    The German (broken) page: https://i.imgur.com/HlDk4QO.png
    The German (fixed with code snippet from original post) page: https://i.imgur.com/knnnMm3.png

    The important part is that the second language is German (or Danish), otherwise this special behaviour won’t be invoked when filtering attribute names.

    Here’s the database dump from my local test that has the problem: https://www.dropbox.com/s/99zqxmxn4rt4c8i/dump.sql.zip?dl=0

    And here’s the docker-compose.yml that I used

    
    version: '3.3'
    
    services:
       db:
         image: mysql:5.7
         volumes:
          - ./db_data:/var/lib/mysql
         restart: always
         environment:
           MYSQL_ROOT_PASSWORD: somewordpress
           MYSQL_DATABASE: wordpress
           MYSQL_USER: wordpress
           MYSQL_PASSWORD: wordpress
    
       wordpress:
         depends_on:
           - db
         image: wordpress:5.4.2
         ports:
           - "8000:80"
         restart: always
         volumes:
           - ./wp_data:/var/www/html
         environment:
           WORDPRESS_DB_HOST: db:3306
           WORDPRESS_DB_USER: wordpress
           WORDPRESS_DB_PASSWORD: wordpress
           WORDPRESS_DB_NAME: wordpress
    

    Hope this helps to quickly resolve this.

    Thanks!

    Hello,
    Thanks for the details!

    We already aware about issue with German and Danish languages and the fix will be released today https://wpml.org/errata/variations-may-be-missing-in-german-or-danish/

    Sorry, I forgot to ask what is your second language in the previous reply…

    Thread Starter buggiesmalls

    (@buggiesmalls)

    Sorry, I forgot to ask what is your second language in the previous reply…

    No worries, I should’ve mentioned it in the original post since it’s an essential part of the affected function.

    I can confirm that 4.10.2 fixes the mixed translated content with my demo setup.

    Thanks for the quick fix and swift responses!

    Marking as resolved ??

    Thanks for your confirmation!

    Have a nice day or evening =)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[4.10.1] Possible bug when filtering attribute names’ is closed to new replies.