#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 |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.7 |
| Component: | Posts, Post Types | Version: | 3.0 |
| Severity: | trivial | Keywords: | has-patch |
| Cc: | Focuses: |
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
@
13 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
@
13 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
@
13 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
@
13 years ago
Except for the typo in the query. Fat fingers. 24803.3.diff is the patch, though. Unit tests are forthcoming.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Updated patch with feedback from Aaron Campbell