[wp-trac] [WordPress Trac] #63975: wp_delete_auto_drafts passes post ID as string instead of as int
WordPress Trac
noreply at wordpress.org
Sun Sep 28 21:03:10 UTC 2025
#63975: wp_delete_auto_drafts passes post ID as string instead of as int
-------------------------------------------------+-------------------------
Reporter: kkmuffme | Owner:
| westonruter
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: Future
| Release
Component: Posts, Post Types | Version: 3.4
Severity: trivial | Resolution:
Keywords: has-test-info needs-testing has- | Focuses:
patch changes-requested needs-unit-tests |
-------------------------------------------------+-------------------------
Changes (by westonruter):
* keywords: has-test-info needs-testing has-patch commit =>
has-test-info needs-testing has-patch changes-requested needs-unit-
tests
Comment:
I'm just realizing the phpdoc for the `$post_id` param says "Optional.
Post ID. Default 0." This actually is NOT optional. If a `$post_id` of `0`
is passed, then the SQL query will look for a `wp_posts` row with an `ID`
of `0` which should never happen. I think the phpdoc should be updated to
say:
{{{
* @param int $post_id Post ID.
}}}
The default value of `0` should still be kept for the `$post_id` param,
just in case there is any plugin not supplying a value. I can't imagine
why this function would have allowed the global to be used as the default,
but maybe it used to be the case.
I'm not really seeing any good unit test coverage for this
`wp_delete_post()` function. This seems like a good time to add it.
@SirLouen Do you want to do so?
See [https://github.com/WordPress/wordpress-
develop/pull/10061#pullrequestreview-3277377775 PR review].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63975#comment:31>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list