[wp-trac] [WordPress Trac] #32991: wp_delete_post() does not return a WP_Post object
WordPress Trac
noreply at wordpress.org
Fri Jul 31 11:48:41 UTC 2015
#32991: wp_delete_post() does not return a WP_Post object
------------------------------------------------+--------------------------
Reporter: johnbillion | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future
Component: Posts, Post Types | Release
Severity: normal | Version:
Keywords: needs-docs needs-patch 2nd-opinion | Resolution:
| Focuses:
------------------------------------------------+--------------------------
Comment (by flixos90):
Replying to [comment:1 DrewAPicture]:
> Turns out that the return documentation is actually ''still'' incorrect
because `wp_trash_post()` can return a `WP_Post` object. Should be
`array|false|stdClass|WP_Post`, though once we get above about three or
four types it makes a lot more sense to use something like a `mixed` type
for readability (what it used to be prior to [29093]).
Same goes for the documentation of `wp_delete_post_revision()` where it
also says it can return `array|false|WP_Post|WP_Error|null`. As far as I
can see it, the function can only return `array|false|stdClass` currently
(not sure where the `WP_Error` and `null` come from).
> For that matter, looks like `wp_delete_attachment()` also returns the
row instead of a `WP_Post` object though `wp_trash_post()` returns a
`WP_Post` object.
I'm wondering why `wp_trash_post()` and `wp_untrash_post()` return a post
array, shouldn't they be adjusted to return an actual `WP_Post` as well to
be conform (documentation is incorrect as well, not stating that an array
could be returned)? Since the caller of the trash/untrash functions must
assume the return value might be a `WP_Post` anyway, there should not be
any compatibility issues I think. This way all those functions would
always return a `WP_Post`, never a post array.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32991#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list