woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.43k stars 10.77k forks source link

Pending comments show wrong count when there is no comment #19621

Closed chxzqw closed 6 years ago

chxzqw commented 6 years ago

Prerequisites

Steps to reproduce the issue

  1. get into the admin panel.
  2. click 'Comments' section with the wrong count on left side.
  3. check both 'All' and 'Pending' column with the wrong count and there is no comment listed.

Expected/actual behavior

The comments count should show zero as there is no records in wp_comments and relative data tables, or at least it should display the existing comments.

Isolating the problem

WordPress Environment

### WordPress Environment ### Home URL: https://www.ningcare.com.au Site URL: https://www.ningcare.com.au WC Version: 3.3.4 Log Directory Writable: ✔ WP Version: 4.9.5 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ✔ Language: en_AU ### Server Environment ### Server Info: Apache/2.4.25 (Debian) PHP Version: 7.2.3 PHP Post Max Size: 8 MB PHP Time Limit: 30 PHP Max Input Vars: 1000 cURL Version: 7.52.1 OpenSSL/1.0.2l SUHOSIN Installed: – Max Upload Size: 2 MB Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ GZip: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Database ### WC Database Version: 3.3.4 WC Database Prefix: wp_ MaxMind GeoIP Database: ✔ Total Database Size: 49.95MB Database Data Size: 32.19MB Database Index Size: 17.76MB wp_woocommerce_sessions: Data: 1.05MB + Index: 0.02MB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.05MB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.05MB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.05MB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB wp_aiowps_events: Data: 0.02MB + Index: 0.00MB wp_aiowps_failed_logins: Data: 0.02MB + Index: 0.00MB wp_aiowps_global_meta: Data: 0.02MB + Index: 0.00MB wp_aiowps_login_activity: Data: 0.02MB + Index: 0.00MB wp_aiowps_login_lockdown: Data: 0.02MB + Index: 0.00MB wp_aiowps_permanent_block: Data: 0.02MB + Index: 0.00MB wp_commentmeta: Data: 0.02MB + Index: 0.03MB wp_comments: Data: 0.02MB + Index: 0.09MB wp_duplicator_packages: Data: 0.02MB + Index: 0.02MB wp_icl_cms_nav_cache: Data: 0.00MB + Index: 0.00MB wp_icl_content_status: Data: 0.02MB + Index: 0.02MB wp_icl_core_status: Data: 0.02MB + Index: 0.02MB wp_icl_flags: Data: 0.02MB + Index: 0.02MB wp_icl_languages: Data: 0.02MB + Index: 0.03MB wp_icl_languages_translations: Data: 0.20MB + Index: 0.14MB wp_icl_locale_map: Data: 0.02MB + Index: 0.02MB wp_icl_message_status: Data: 0.02MB + Index: 0.03MB wp_icl_mo_files_domains: Data: 0.02MB + Index: 0.02MB wp_icl_node: Data: 0.02MB + Index: 0.00MB wp_icl_reminders: Data: 0.02MB + Index: 0.00MB wp_icl_strings: Data: 5.52MB + Index: 6.55MB wp_icl_string_packages: Data: 0.02MB + Index: 0.00MB wp_icl_string_pages: Data: 0.11MB + Index: 0.06MB wp_icl_string_positions: Data: 0.44MB + Index: 0.11MB wp_icl_string_status: Data: 0.02MB + Index: 0.02MB wp_icl_string_translations: Data: 3.52MB + Index: 1.52MB wp_icl_string_urls: Data: 0.02MB + Index: 0.02MB wp_icl_translate: Data: 0.17MB + Index: 0.02MB wp_icl_translate_job: Data: 0.02MB + Index: 0.02MB wp_icl_translations: Data: 0.06MB + Index: 0.06MB wp_icl_translation_batches: Data: 0.02MB + Index: 0.00MB wp_icl_translation_status: Data: 0.17MB + Index: 0.02MB wp_links: Data: 0.02MB + Index: 0.02MB wp_options: Data: 2.25MB + Index: 0.06MB wp_pmxi_files: Data: 0.02MB + Index: 0.00MB wp_pmxi_history: Data: 0.02MB + Index: 0.00MB wp_pmxi_imports: Data: 0.02MB + Index: 0.00MB wp_pmxi_posts: Data: 0.02MB + Index: 0.00MB wp_pmxi_templates: Data: 0.02MB + Index: 0.00MB wp_postmeta: Data: 1.52MB + Index: 0.58MB wp_posts: Data: 1.52MB + Index: 0.06MB wp_smush_dir_images: Data: 0.02MB + Index: 0.03MB wp_termmeta: Data: 0.02MB + Index: 0.03MB wp_terms: Data: 0.02MB + Index: 0.03MB wp_term_relationships: Data: 0.02MB + Index: 0.02MB wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB wp_usermeta: Data: 4.52MB + Index: 6.03MB wp_users: Data: 1.52MB + Index: 0.80MB wp_wcpdf_invoice_number: Data: 0.02MB + Index: 0.00MB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB wp_wfBadLeechers: Data: 0.02MB + Index: 0.00MB wp_wfBlockedCommentLog: Data: 0.02MB + Index: 0.00MB wp_wfBlockedIPLog: Data: 0.02MB + Index: 0.00MB wp_wfBlocks: Data: 0.02MB + Index: 0.02MB wp_wfBlocks7: Data: 0.02MB + Index: 0.05MB wp_wfBlocksAdv: Data: 0.02MB + Index: 0.00MB wp_wfConfig: Data: 0.34MB + Index: 0.00MB wp_wfCrawlers: Data: 0.02MB + Index: 0.00MB wp_wfFileChanges: Data: 0.02MB + Index: 0.00MB wp_wfFileMods: Data: 3.52MB + Index: 0.00MB wp_wfHits: Data: 1.02MB + Index: 0.22MB wp_wfHoover: Data: 1.52MB + Index: 0.14MB wp_wfIssues: Data: 0.02MB + Index: 0.06MB wp_wfKnownFileList: Data: 1.52MB + Index: 0.00MB wp_wfLeechers: Data: 0.02MB + Index: 0.00MB wp_wfLockedOut: Data: 0.02MB + Index: 0.00MB wp_wfLocs: Data: 0.02MB + Index: 0.00MB wp_wfLogins: Data: 0.09MB + Index: 0.03MB wp_wfNet404s: Data: 0.02MB + Index: 0.02MB wp_wfNotifications: Data: 0.05MB + Index: 0.00MB wp_wfPendingIssues: Data: 0.02MB + Index: 0.06MB wp_wfReverseCache: Data: 0.02MB + Index: 0.00MB wp_wfScanners: Data: 0.02MB + Index: 0.00MB wp_wfSNIPCache: Data: 0.02MB + Index: 0.05MB wp_wfStatus: Data: 0.14MB + Index: 0.09MB wp_wfThrottleLog: Data: 0.02MB + Index: 0.02MB wp_wfVulnScanners: Data: 0.02MB + Index: 0.00MB wp_wpc_comments_subscription: Data: 0.00MB + Index: 0.00MB wp_wpc_phrases: Data: 0.00MB + Index: 0.00MB wp_wpc_users_voted: Data: 0.00MB + Index: 0.00MB wp_yoast_seo_links: Data: 0.02MB + Index: 0.02MB wp_yoast_seo_meta: Data: 0.02MB + Index: 0.00MB ### Post Type Counts ### attachment: 150 customize_changeset: 8 nav_menu_item: 26 page: 26 post: 1 product: 98 product_variation: 8 revision: 50 shop_order: 1 ### Security ### Secure connection (HTTPS): ✔ Hide errors from visitors: ✔ ### Active Plugins (34) ### WPML Multilingual CMS: by OnTheGoSystems – 3.9.3 Advanced Custom Fields Multilingual: by OnTheGoSystems – 0.7 Akismet Anti-Spam: by Automattic – 4.0.3 Debug Info: by Scott DeLuzio – 1.3.6 Duplicator: by Snap Creek – 1.2.34 Google Analytics Dashboard for WP (GADWP): by Alin Marcu – 5.3.2 Maintenance: by fruitfulcode – 3.6.1 Merge + Minify + Refresh: by Launch Interactive – 1.8.9 PayPal for WooCommerce: by Angell EYE – 1.4.8.7 Revision Control: by Dion Hulse – 2.3.2 Server IP & Memory Usage Display: by Apasionados Apasionados del Marketing – 2.1.0 Storefront Designer: by WooThemes – 1.8.4 Storefront Site Logo: by Wooassist – 1.2.2 Storefront WooCommerce Customiser: by WooThemes – 1.9.2 – Not tested with the active version of WooCommerce Theme Check: by Otto42 pross – 20160523.1 Woocommerce Add Countries: by Daniele De Santis – 1.1 – Not tested with the active version of WooCommerce Woocommerce CSV Import: by Allaerd Mensonides – 3.3.6 – Not tested with the active version of WooCommerce WooCommerce Gateways Country Limiter: by OnTheGoSystems – 1.4 – Not tested with the active version of WooCommerce WooCommerce Multilingual: by OnTheGoSystems – 4.2.9 WooCommerce PDF Invoices & Packing Slips: by Ewout Fernhout – 2.1.6 WooCommerce: by Automattic – 3.3.4 Wordfence Security: by Wordfence – 7.1.2 Yoast SEO: by Team Yoast – 7.2 WP All Import: by Soflyy – 3.4.7 WP Crontrol: by John Blackbourn & contributors – 1.6.2 WP Smush: by WPMU DEV – 2.7.8 WP Super Cache: by Automattic – 1.5.9 WPML All Import: by OnTheGoSystems – 2.0.5 WPML CMS Nav: by OnTheGoSystems – 1.4.22 WPML Media: by OnTheGoSystems – 2.2.3 WPML Sticky Links: by OnTheGoSystems – 1.4.3 WPML String Translation: by OnTheGoSystems – 2.7.3 WPML Translation Management: by OnTheGoSystems – 2.5.2 WPS Hide Login: by WPServeur NicolasKulka tabrisrp – 1.2.6.1 ### Settings ### API Enabled: ✔ Force SSL: ✔ Currency: AUD ($) Currency Position: left Thousand Separator: , Decimal Separator: . Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) variable (variable) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) ### WC Pages ### Shop base: #5 - /shop/ Cart: #6 - /cart/ Checkout: #7 - /checkout/ My account: #8 - /my-account/ Terms and conditions: #121 - /terms-and-conditions/ ### Theme ### Name: Ningcare Storefront Version: 1.0.0 Author URL: http://example.com Child Theme: ✔ Parent Theme Name: Storefront Parent Theme Version: 2.2.8 Parent Theme Author URL: https://woocommerce.com/ WooCommerce Support: ✔ ### Templates ### Overrides: ningcare-storefront/woocommerce/cart/cart-empty.php

Screenshot

image

peterfabian commented 6 years ago

Hi Sid,

You say that your wp_comments is empty, but I can see in your status report that wp_comments: Data: 0.02MB + Index: 0.09MB

which shows that most likely there are some rows in the wp_comments table.

WooCommerce also uses wp_comments to store order notes and webhook_delivery notes, so maybe those are not correctly filtered out when the comments are displayed in your installation in case there is some conflict with other plugins. Can you please check if the table wp_comments is really empty?

Additionally, it looks like the number of comments is cached in a transient. Can you please try to Clear transients and see if the problem gets solved (in admin, WooCommerce > Status > Tools > Clear transients)?

Last, I can see you're using WPML Multilingual CMS plugin, which might be filtering out comments in other languages, so that might also be a reason why you see no comments in your admin, even though they are probably somewhere in the database.

However, I could not reproduce this issue on a clean WordPress with WooCommerce installation, so I will close this ticket now. Feel free to create a new ticket if you find out this is a WooCommerce bug.

chxzqw commented 6 years ago

Hi Peter,

Thank you for your time reading my post.

I didn't notice that the status report says that wp_comments has got some 'hidden' data usage however I am sure that wp_comments table is empty. Below is the screenshot from phpmyadmin.

image

I have just tried both the 2 'Clear transients' from WooCommerce status tools page but no luck.

I am already aware of that WPML plugins could cause the issue. However as long as WooCommerce is activated, the wrong count appears, while WooCommerce is deactivated, the count is gone and it doesn't matter WPML plugins are activated or not. So I think it relates to WooCommerce.

This site is just immigrated from other VPS and I used duplicator to do the job, which might cause the issue?

Any help is appreciated.

peterfabian commented 6 years ago

Hi,

Have you tried it the other way around, i.e. to disable all plugins and then only have WooCommerce enabled to see if this still happens?

In addition, you can try to install a very useful plugin called Query Monitor and check how your queries to wp_comments look like. E.g. you can then check how your queries look like when calling get_pending_comments_num() or wp_count_comments() (I would compare the query when you get the correct vs incorrect result):

image wp_comments_query1
chxzqw commented 6 years ago

Hi just let you know I finally sort it out.

It was caused by a wc transient entry in wp_options, which can't be cleared by from WooCommerce status page. image

The issue is gone after I manually deleted it. Thanks again for any help and the monitor plugin. Much appreciated.

peterfabian commented 6 years ago

Thanks for letting us know, I wrongly assumed that it would be cleared by the Clear transient button. @mikejolley probably low prio, but should we maybe add comment transients to the list of cleared transients?

mikejolley commented 6 years ago

@peterfabian Yeah please add that to the whitelist.

sparky672 commented 6 years ago

Nothing worked for me. Disabling WooCommerce correctly restores the comment counts.

Cleared all transients as per the WooCommerce Status - no effect.

Cleared out the value of _transients_wc_count_comments - no effect.

I had to also clear out the value of _transient_as_comment_count and it finally worked.

So far I've had this issue on two completely different WP sites running WooCommerce. One was fixed by using the Clear Transient buttons in WooCommerce and the other required my editing the wp_options table as per procedure above.

I wish WooCommerce would finally fix this issue!

diyafury commented 4 years ago

Awesome!! thank you, I am doing a mammoth data sync between and old site and a new site... was looking for this.

oempire commented 4 years ago

im still having this issue with _transient_as_comment_count

h-sobhy commented 2 years ago

In my case (WP 5.6x) changing the value(s) of _transient_as_comment_count in DB didn't work. Adding new POST comment corrected both "All" and "Pending" comments count.

codewithiulian commented 7 months ago

In my case (WP 5.6x) changing the value(s) of _transient_as_comment_count in DB didn't work. Adding new POST comment corrected both "All" and "Pending" comments count.

Same, fixed it by adding a new comment, thanks!