[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:06:30 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 |
-------------------------------------------------+-------------------------
Comment (by westonruter):
For reference, this `wp_delete_post()` function
[https://github.com/WordPress/wordpress-
develop/blob/004508b63f772b3c976f2ce4b36e151c69234e26/wp-includes
/functions-post.php#L216-L235 looked like this] back in WP 1.5.0:
{{{#!php
<?php
function wp_delete_post($postid = 0) {
global $wpdb;
$postid = (int) $postid;
if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID
= $postid") )
return $post;
if ( 'static' == $post->post_status )
$wpdb->query("UPDATE $wpdb->posts SET post_parent =
$post->post_parent WHERE post_parent = $postid AND post_status =
'static'");
$wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid");
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID =
$postid");
$wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id =
$postid");
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id =
$postid");
return $post;
}
}}}
Even back then it had a default value of `0` for `$postid`, but it would
never succeed back then either because it doesn't supply the global
`$post` for the post ID when `0` is supplied.
Interestingly, back then it did have a cast to `(int)`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63975#comment:32>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list