#24803 closed defect (bug) (fixed)
wp_counts_posts produces a notice if a non existant post type is specified
Reported by: | creativeinfusion | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | trivial | Version: | 3.0 |
Component: | Posts, Post Types | Keywords: | has-patch |
Focuses: | Cc: |
Description
Calling wp_count_posts with a non existant post type and perm='readable' produces a notice.
wp_count_posts ('doesnotexist', 'readable') will generate
Notice: Trying to get property of non-object in wp-includes/post.php
Attachments (4)
Change History (12)
#2
@
11 years ago
Instead of checking the post type, it would make more sense for the function to simply return an empty object right away.
#3
@
11 years ago
WP_Error might be better but this function has existed around too long, and it doesn't fail hard enough to justify a new return type.
#4
@
11 years ago
Yeah, the second patch returns WP_Error; if we want to do it that way, we can just use that patch. :D
#5
@
11 years ago
Except for the typo in the query. Fat fingers. 24803.3.diff is the patch, though. Unit tests are forthcoming.
#6
@
11 years ago
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed
In 24826:
Note: See
TracTickets for help on using
tickets.
Updated patch with feedback from Aaron Campbell