[wp-trac] [WordPress Trac] #32366: wp_count_comments() is hardcoded into /wp-admin/menu.php and queries all comments every single page load within the admin area, regardless of if edt_posts is removed from top menu or not

WordPress Trac noreply at wordpress.org
Thu Dec 27 16:58:55 UTC 2018


#32366: wp_count_comments() is hardcoded into /wp-admin/menu.php and queries all
comments every single page load within the admin area, regardless of if
edt_posts is removed from top menu or not
-----------------------------+------------------------------------------
 Reporter:  justindocanto    |       Owner:  (none)
     Type:  defect (bug)     |      Status:  reopened
 Priority:  normal           |   Milestone:
Component:  Comments         |     Version:  4.2
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |     Focuses:  administration, performance
-----------------------------+------------------------------------------
Changes (by lkraav):

 * status:  closed => reopened
 * resolution:  wontfix =>


Comment:

 > With the introduction of the wp_count_comments in #35060 you can skip
 the comment count query from running. I don't think we need another
 filter.

 @rachelbaker above conclusion seems to be a solid fit only for simple
 scenarios.

 When multiple plugins `add_filter wp_count_comments`, each with their own
 logic, possibly making heavy queries, situation becomes significantly more
 complex.

 It is not possible to safely unhook this filter from everyone, because in-
 depth knowledge about why things are done the way they are may not
 be(come) available.

 Because comments model is being used for a variety of non-UI utilities
 (Action Scheduler, Sensei LMS), it is not reasonable anymore (probably for
 a long time already) to assume `menu.php` firing off `wp_count_comments()`
 is safe and performant everywhere.

 I vote to reopen and rearchitect "Comments" admin menu item display,
 because the performance hit can be very significant (admin page load times
 increase by a factor of 10+, depending on comment db size), for trivial
 gains (menu item badge).

 Example: https://github.com/Automattic/sensei/blob/version/1.12.2/includes
 /class-sensei.php#L894

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/32366#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list