[Resolved] Menu sync time out issue - workaround or Patch?
This thread is resolved. Here is a description of the problem and solution.
Problem: The client is experiencing timeouts with Cloudflare when using WPML to synchronize and translate menus due to high resource usage and extensive database queries. This issue is exacerbated by the n+1 query problem with a large number of menu options and languages. Solution: We recommend the following workarounds to address the timeout issue: 1. Manually translate the menu to avoid triggering the resource-intensive synchronization process. 2. Temporarily disable Cloudflare while running the menu synchronization or translation process, which will prevent Cloudflare from stopping the request. 3. Consider upgrading to Cloudflare Pro, which allows for a higher timeout limit (up to 100 seconds), potentially preventing these interruptions.
If these solutions do not resolve your issue or seem outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket at WPML support forum for further assistance.
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.
The cause of the issue is the number of menu items to synchronize, so our 2nd tier specialists created this workaround to sync the menu items in batches:
They can open the browser console and use this code to select the first, say, 100 checkboxes, then scroll to the bottom and run the sync. They'll have to reload the page afterwards and go through the same steps to do another batch, etc.
document.querySelectorAll(".wpml-checkbox-native").forEach((cb, i) => {
if (i < 100) cb.checked = true;
});
Please try this workaround and let me know the results. Or let me know if you need more assistance.
Hello Carlos
For some reason, I don't receive email notifications. Is it possible for you to help me to receive them? I am afraid that it will be closed without my notice.
one important question,
Is it true that WPML menu sync is useless for a site have over 10 languages? Is there a limit to languages in order for WPML to have menu sync?
THanks
Good to hear that there is no number of language limit.
we treid to follow your advise but here is the problem. message from my colleague.
"To implement this solution, we would first need to be able to access the WP Menus Sync page, which is not currently possible. Displaying the WP Menus Sync page takes far too much time and resources; this problem must be addressed before proceeding with the solution proposed by WPML for synchronizing menus.
I remember you already raised this issue with a consultant, and he ran a test on a local computer. Just to load the page, it took 20 minutes, I think. I could be wrong, but I believe that was the case.
First, we need to address the display of the WP Menus Sync page."
This was THE issue: unable to sync because it times out. unable to open the menu sync itself. Please help us. It's getting a big problem.
After investigating, we’ve found that the menu synchronization process on your site is being significantly slowed down due to server limitations, especially given the number of active languages. While we tested the process locally and, although it runs slowly, it does complete successfully, it seems your current server setup may not have enough resources to handle it all at once.
Unfortunately, the code behind this feature doesn’t support syncing one language at a time easily. However, there is a workaround you could try:
Recommended Workaround (Manual Batch Sync):
- Temporarily deactivate some of your languages from WPML > Languages.
- Run the Menu Sync for the remaining active languages.
- Once complete, deactivate those languages and reactivate the others.
- Run Menu Sync again for the newly activated languages.
- Repeat the process until all menus are synced.
This approach essentially divides the workload into smaller batches that your server can better manage. While not ideal, it's currently the most reliable way to proceed without triggering server timeouts or errors.
Yes, you can create a staging site, try it there, and then restore the staging on the production site or replicate the steps directly on the production site.
Is it possible that you temporarily migrate the site or a copy of the site to a different hosting and confirm that with only 30% of the language active, you can sync the menus?