Skip Navigation

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.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Lucas Vidal de Andrade 2 months, 3 weeks ago.

Assisted by: Lucas Vidal de Andrade.

Author Posts
July 2, 2024 at 1:36 pm #15875844

sissiB

Background of the issue:
I am trying to hook into the action admin_bar_menu() and walk through all blogs in a WordPress multisite setup. The current blog I am on has WPML active, as do blog IDs 2 and 4. Blog ID 3 does not have WPML active. When switching between blogs using switch_to_blog($blogid) and calling wp_count_comments(), I get an error for blog ID 3 that the table 'client_wp_3_icl_translations' doesn't exist. After calling wp_count_comments(), I call restore_current_blog().

Symptoms:
I get a WordPress database error: Table 'client_wp_3_icl_translations' doesn't exist for query SELECT COUNT(*) FROM client_wp_3_comments JOIN client_wp_3_icl_translations icltr2 ON icltr2.element_id = client_wp_3_comments.comment_post_ID JOIN client_wp_3_posts ON client_wp_3_posts.ID = icltr2.element_id AND CONCAT('post_', client_wp_3_posts.post_type) = icltr2.element_type LEFT JOIN client_wp_3_icl_translations icltr_comment ON icltr_comment.element_id = client_wp_3_comments.comment_ID AND icltr_comment.element_type = 'comment' WHERE (comment_approved = '1') AND icltr2.language_code = 'de' AND (icltr_comment.language_code IS NULL OR icltr_comment.language_code = icltr2.language_code) made by require_once('wp-admin/admin-header.php'), do_action('in_admin_header'), WP_Hook->do_action, WP_Hook->apply_filters, wp_admin_bar_render, do_action_ref_array('admin_bar_menu'), WP_Hook->do_action, WP_Hook->apply_filters, Multisite_EnhancementsAdmin_Bar_Tweaks->enhance_network_blog_admin_bar, wp_count_comments, get_comment_count, get_comments, WP_Comment_Query->query, WP_Comment_Query->get_comments, WP_Comment_Query->get_comment_ids.

Questions:
Why am I getting a database error when calling wp_count_comments() on a blog where WPML is not active?
How can I prevent WPML from hooking into a blog site that does not have WPML active when calling wp_count_comments()?

July 2, 2024 at 3:02 pm #15876455

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to a testing site where the issue is replicated.

You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” or "All in One WP Migration" on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved I will delete the local site. Let me know if this is ok with you.

IMPORTANT

- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this:

hidden link

July 3, 2024 at 12:26 pm #15884175

sissiB

After trying to replicate this on a staging environment, it seems this issue only happens locally in my test environment, so I suppose that I have an issue here with WPML. I cannot reproduce this happening on another testing environment.

sissiB confirmed that the issue was resolved on 2024-07-03 12:26:23.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.