Support » Plugin: WooCommerce Multilingual - run WooCommerce with WPML » Bug: Product taxonomy synchronization term_id type casting

  • Resolved veisis

    (@veisis)


    File: class-wcml-synchronize-product-data.php
    Function: wcml_update_term_count_by_ids
    Line: 251
    Needs to type cast term_id as integer:
    Original:
    $terms_ids_array[] = $translated_term->term_id;
    Change to:
    $terms_ids_array[] = (int)$translated_term->term_id;

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support George Botsev

    (@botzev)

    Do you have any specific issues with that value not being an integer?
    Would you please clarify a bit more about this change?

    Thread Starter veisis

    (@veisis)

    $translated_term->term_id gets returned as string but wp_set_post_terms require that term_id is integer.
    See example here:
    https://codex.wordpress.org/Function_Reference/wp_set_post_terms

    Basically if term is string than wp_set_post_terms will create new term instead of linking with existing term. This is what exactly happened to one of my client shop products. Adding type casting fixed problem.

    This bug vas introduced in version 3.9.4 when sync_product_taxonomies function was refactored.

    Plugin Support George Botsev

    (@botzev)

    Thank you for the clarification. I will escalate this to our developers as well.

    Plugin Support George Botsev

    (@botzev)

    Hello, I just talked with one of our developers.
    Did you test to reproduce the same issue with WooCommerce Multilingual 3.9.5 release?
    He assures me that this is fixed at a later stage in the code (using code like: terms_array = array_unique( array_map( 'intval', $terms_array ) );)and there should be no problem with this functionality.

    Thread Starter veisis

    (@veisis)

    Yes i double checked version. It is 3.9.5. I even compare files on svn.

    There is two arrays $terms_array and $terms_ids_array.
    That fix is only for $terms_array. For product_cat and product_tag taxonomy class-wcml-synchronize-product-data.php line 263-266.
    But $terms_ids_array is without fix and is used in line 268.

    Plugin Support George Botsev

    (@botzev)

    Okay, I see that this is changed in the next release of WooCommerce Multilingual
    If you wish, here is a diff file with the changes against 3.9.5 for you to test with: http://pastebin.com/b9b7jpX4
    The paste will expire in a month.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Bug: Product taxonomy synchronization term_id type casting’ is closed to new replies.