Please make sure to update to WPML 4.3.4 before reporting any issue

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

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.

This topic contains 12 replies, has 3 voices.

Last updated by Alejandro 2 days, 9 hours ago.

Assigned support staff: Alejandro.

Author Posts
October 21, 2019 at 1:11 pm #4794741

severinP

If you have many products in your shop and you go to /wp-admin/admin.php?page=sitepress-multilingual-cms%2Fmenu%2Ftaxonomy-translation.php

Select a product taxonomy attribute and then at the bottom of the page, click on the button "Synchronize attributes and update product variations"

The request will timeout (depending on the host settings, usually after 1minute)

This is due to a bug in the code in woocommerce-multilingual/inc/class-wcml-terms.php > public function wcml_sync_product_variations

if($variations_processed >= $variations_treshold){
    break; //This should be break 2; (because there is 2 foreach)
}

//...
echo json_encode($response); //This should be wp_send_json($response); (else the correct headers are not sent)
exit;

I also suspect there are issues in the file woocommerce-multilingual/res/js/taxonomy_translation.js that makes the ajax call, the form cannot be resubmitted

The fix would be the following


    $(document).on('submit', '#wcml_tt_sync_variations', function () {

        var this_form = $('#wcml_tt_sync_variations');
        var data = this_form.serialize();
        this_form.find('.wcml_tt_spinner').fadeIn();
        this_form.find('input[type=submit]').attr('disabled', 'disabled');

        recursive_sync(data);

        return false;

    });
    function updateURLParameter(additionalURL, param, paramVal){
        var newAdditionalURL = "";
        var temp = "";
        var tempArray;
        if (additionalURL) {
            tempArray = additionalURL.split("&");
            for (var i=0; i<tempArray.length; i++){
                if(tempArray[i].split('=')[0] != param){
                    newAdditionalURL += temp + tempArray[i];
                    temp = "&";
                }
            }
        }

        var rows_txt = temp + "" + param + "=" + paramVal;
        return newAdditionalURL + rows_txt;
    }

    function recursive_sync(data) {
        $.post(ajaxurl, data, function (response) {
            var this_form = $('#wcml_tt_sync_variations');
            this_form.find('.wcml_tt_sycn_preview').html(response.progress);
            if (response.go) {
                data = updateURLParameter(data, 'last_post_id', response.last_post_id);
                data = updateURLParameter(data, 'languages_processed', response.languages_processed);
                recursive_sync(data);
            } else {
                this_form.find('input[name=last_post_id]').val(0);
                this_form.find('.wcml_tt_spinner').fadeOut();
                this_form.find('input').removeAttr('disabled');
                jQuery('#wcml_tt_sync_assignment').fadeOut();
                jQuery('#wcml_tt_sync_desc').fadeOut();
            }

        });
    }
October 21, 2019 at 1:45 pm #4794981

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hello,

I decided to reopen this ticket because i'd like to know a bit more about this issue.
Last time our developer asked us for an example where the problem was reproduced, because they couldn't replicate the problem.

I went ahead and created over 800 sub-attributes which were part of 2 different attributes and i translated roughly 100 of them.

For me the synchronize button works as expected and is not timing out.

Since i'm trying to replicate this problem on a newer version of WPML, i believe there are 2 scenarios that we should consider:

1) The problem is not reproduceable anymore in the latest version of WPML:
I see that due to several changes in the way WPML works now, woocommerce-multilingual/inc/class-wcml-terms.php > public function wcml_sync_product_variations
now has a different approach to the issue at hand and if you check it now, you'll see the code is different now (or at least that's what i could see when i checked the code a few minutes ago).

About the JS file, i wouldn't know if the code provided would still help, although maybe it could be a different approach to still solve the same issue.

2) The problem could still be there but i'm missing some steps that you took.

I couldn't replicate the problem on this sandbox (clean and new environment), so if you want you're welcome to give it a try, maybe i'm missing some steps and if that's the case then please let me know all the steps taken in order to recreate the issue.

Please let me know if the problem still happens now so i know how to proceed.

Regards and again thanks for spotting this issue.

October 28, 2019 at 10:49 am #4838439

severinP

Hello,

I have checked with the current version of wpml, the issue is still partially present

While the type of the data received has been fixed on the js side (which is the wrong way to do this, see wp_send_json for correct headers)

So while the loop on the js side works, because of logic problem on the php side the request still might timeout after 2 or 3 requests

The suggested fix of break 2; is still the valid solution again because the break; in the code does not fulfill it's intended function that is to exit the loop when more than 20 variations have been processed to avoid a timeout

Currently while the second loop will stop executing the first loop will still run and run expensive database querying operations while the second loop which does the updates does not run.

The part that will run every request for all of the posts instead of just 20 times is the following, which is very expensive as you can imagine

                $terms = wp_get_post_terms($post_id, $taxonomy);    
                $terms_count = count($terms);
                
                $trid = $this->sitepress->get_element_trid($post_id, 'post_product');
                $translations = $this->sitepress->get_element_translations($trid, 'post_product');
              
October 28, 2019 at 10:57 am #4838483

severinP

Also my provided js fix did have one improvement in it that I would like to see implemented

It allowed for the sync to be run on multiples taxonomies at the same time on the same page by keeping the data in memory instead of setting form values and resending the form, because the data will conflict if you launch a sync then change the taxonomy to sync, the previous sync will be stoped because the form has been removed from the DOM

October 28, 2019 at 11:20 am #4838643

severinP

I tried to send some git diffs in [php] tags but the server filter is denying the post (403 error) probably thinking I'm trying to do a php inject or something

October 28, 2019 at 4:46 pm #4841865

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

I'm sending all this observations to our developers so they can test it out and see if they can get them implemented in our plugin.

I'll update you when they get back to me and this time i'll keep the ticket as assigned so it doesn't get closed.

Regards.

October 30, 2019 at 12:20 pm #4855481

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hello,

Would you mind telling me exactly which parts of our code are you modifying by yours? i mean, not only the filename but also the lines of code, that way i can send them to our developers given that since i'm unable to replicate the problem and you're not willing to provide us a copy of a site where the problem is being created, it's very difficult for us to troubleshoot the issue and at this point guess which lines of code are you modifying or changing altogether.

Thanks in advance for the answer.

October 30, 2019 at 3:12 pm #4856975

severinP

Hello,

That's what I was trying to provide in code tags but I couldn't (server is denying me with error 403)

Could you open a file request so I can send it as a file?

October 30, 2019 at 3:25 pm #4857371

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Sure, you can add it where it says "Database dump" which i just enabled for you.

Thanks in advance!

October 31, 2019 at 10:12 am #4862187

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hello,

I just wanted to let you know that our developers are looking into the diff file you sent us and will probably get back to us soon.

I'll keep you updated and in the meantime i really thank you for the code you have provided us, hopefully it will be implemented in our code.

Regards.

November 4, 2019 at 4:27 pm #4883159

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hello,

Our devs couldn't reproduce your problems but they asked if you could send a dump of the WPML (icl_ ) and default WP tables, that way all the information of your client wouldn't be touched and it would be safe for us to safely reproduce the problem and try to fix the issue.

It does seem that your suggestion could help, but of course without reproducing the issue we won't be able to test and Unit test this scenario.

Hope you can help us out. I enabled a database dump field so you can send the link to download it there safely and privately.

Regards.

November 8, 2019 at 10:11 am #4912057

SergeyR
Supporter

Helo Severin,
Thanks for reporting this and proposed a fix.

We will review it in one of the next our releases.

You can also use troubleshooting page to synchronize product variations

wp-admin/admin.php?page=wpml-wcml&tab=troubleshooting
November 15, 2019 at 8:38 am #4951847

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hello,

Just FYI, Sergey is one of our WooCommerce Multilingual developers.

If you can try the method he described just to rule out a possible solution (although I believe you have already tried this).

Let me know how it goes, and again, if you can provide us with something, anything where we can test this scenario you mention with our developers, that will probably speed things up.

Regards.

Regards.