Background of the issue:
I am trying to save a new menu item and sync it into other languages on my WordPress site. The issue can be seen at hidden link.
Symptoms:
It takes more than 4 minutes to save a new menu item and even longer to sync it into other languages. This is a speed issue on my backend.
Questions:
How do I improve my speed when working with Menus
I've converted the chat into a ticket since I'm not getting any response from your end. I've checked your Website and I can see that you've so many navigation menus and languages.
I will need to closely examine your website. Therefore, I will require temporary access (WP-Admin and FTP) to a test site where the problem has been replicated, if possible. This will enable me to provide better assistance and determine if any configurations need to be modified.
Please note that it is important to have a backup for security purposes and to prevent any potential data loss. You can use the UpdraftPlus plugin (https://wordpress.org/plugins/updraftplus/) to fulfill your backup requirements.
Your upcoming reply will be treated with confidentiality and will only be visible to you and me.
✙ To resolve the issue, I may need your consent to deactivate and reactivate plugins and the theme, as well as make configuration changes on the site if necessary. This emphasizes the significance of having a backup.
I encounter an issue when attempting to access the menu sync option; it displays a "A timeout occurred" page when it fails to load. Could you please reach out to your hosting provider to check the error logs? Additionally, ask them to increase the server resources as much as possible and temporarily disable the CloudFlare CDN.
Currently, I am unable to open any pages in the backend of the site, as it continuously shows "A timeout occurred."
It looks like every time I open the menu sync feature, the Website crashes due to insufficient resources.
I regret any inconvenience caused, but to proceed with troubleshooting, I kindly ask for a snapshot of the site. Alternatively, with your permission, I can create one myself. For this purpose, I typically recommend using the free plugin "Duplicator." If you're already familiar with Duplicator (https://wordpress.org/plugins/duplicator/), please skip the following steps and simply send me the archive file you downloaded.
To guide you further, please adhere to these instructions:
1. View the Duplicator instructions video: hidden link
3. If the archive file exceeds 400MB, please use Duplicator's file filters to exclude cache, wp-uploads directory, media, and archive files.
Once you have the archive file ready, kindly share the link with us. You can utilize platforms like Google Drive, Dropbox, or similar for file sharing, as the snapshot file might be large.
Please note that your next reply will be private, visible only to you and me. You can paste the file link there. Rest assured that once the issue is resolved, I will delete the local site.
I have feedback and our 2nd Tier Support shared some workarounds.
The issues is caused by \WPML_Menu_Sync_Functionality::get_page_orphan_sql in wp-content/plugins/sitepress-multilingual-cms/inc/wp-nav-menus/wpml-menu-sync-functionality.class.php
rewriting the function to the below should help a bit. Menu sync should be run with patience as the logic is a bit old. Maybe a better alternative is to manually translate the menus. Anyhow, this is escalated to our devs for further investigation.
private function get_page_orphan_sql( $existing_languages, $menu_item_id ) {
$wpdb = &$this->wpdb;
// Prepare the NOT IN list
$existing_languages_in_clause = wpml_prepare_in( $existing_languages );
// Build the SQL query with early filtering and improved structure
return $wpdb->prepare(
"SELECT it.element_id, it.language_code
FROM {$wpdb->prefix}icl_translations it
JOIN {$wpdb->posts} pt
ON pt.ID = it.element_id
AND pt.post_type = 'nav_menu_item'
AND it.element_type = 'post_nav_menu_item'
AND it.language_code NOT IN ($existing_languages_in_clause)
JOIN {$wpdb->prefix}icl_translations io
ON io.trid != it.trid
JOIN {$wpdb->posts} po
ON po.ID = io.element_id
AND po.post_type = 'nav_menu_item'
JOIN {$wpdb->postmeta} mo
ON mo.post_id = po.ID
AND mo.meta_key = '_menu_item_object_id'
JOIN {$wpdb->postmeta} mt
ON mt.post_id = pt.ID
AND mt.meta_key = '_menu_item_object_id'
JOIN {$wpdb->prefix}icl_translations page_t
ON mt.meta_value = page_t.element_id
AND page_t.element_type = 'post_page'
WHERE io.element_id = %d
AND EXISTS (
SELECT 1
FROM {$wpdb->prefix}icl_translations count
WHERE count.trid = it.trid
HAVING COUNT(count.element_id) = 1
)",
$menu_item_id
);
}
I've applied the fix to your Website and I can load the menu sync within 2-3 minutes now. It would help a bit but there will be a better solution soon in the future.
the problem is not just with the fact that the synchronizing of the menus is next to impossible. The main issue is that loading a page or post, saving changes etc. takes up to 4 minutes, which makes it extremely difficult to manage the site.
Even the frontend seems to be affected, especially when multiple visitors interact with the site, when multiple pages are opened in new tabs etc.
We urgently need a resolution for this issue!
I apologize for the issues. I've rechecked the report and our 2nd Tier Support has already escalated this to our devs for further review. We are still waiting for their feedback and I've also shared your feedback on the report. I will come back to you once I hear from them.