[wp-trac] [WordPress Trac] #36208: Comment queries should ignore comments associated with non-active custom post types

WordPress Trac noreply at wordpress.org
Fri Mar 11 13:50:30 UTC 2016


#36208: Comment queries should ignore comments associated with non-active custom
post types
--------------------------+----------------------------------------
 Reporter:  Clorith       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  4.4
 Severity:  normal        |   Keywords:  has-patch needs-unit-tests
  Focuses:                |
--------------------------+----------------------------------------
 As of 4.4 we introduced the `_doing_it_wrong()` (r34091) when checking
 meta capabilities on custom post types that aren't registered.

 This also spread and affected comments, primarily on the dashboard where
 we show comments and try to add links for these and check the users
 capability against them, they will produce this wonderful output:

 > PHP Notice:  map_meta_cap was called <strong>incorrectly</strong>. The
 post type shop_order is not registered, so it may not be reliable to check
 the capability "edit_post" against a post of that type. Please see <a
 href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in
 WordPress</a> for more information. (This message was added in version
 4.4.0.) in /wordpress/wp-includes/functions.php on line 3827

 Ideally, `WP_Comment_Query` should bypass comments associated to non-
 existing post types as well.

 In the attached patch I've introduced both `post_type__in` and
 `post_type__not_in` which accepts an array of post type string names.

 I've also added the default value for `post_type__in` to
 `get_post_types()`, as by default you'd never want to query for non-
 existing data any way, but this allows the query to be overwritten via
 filters, or directly with a new construct for those who have the need.

 I am wondering if the use of `post_type = 'any'` would need to short-
 circuit the new arguments to avoid breaking BC (current tests all pass
 with the patch applied though) ?

 Related #16956

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36208>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list