[wp-trac] [WordPress Trac] #63975: wp_delete_auto_drafts passes post ID as string instead of as int

WordPress Trac noreply at wordpress.org
Wed Sep 17 05:07:33 UTC 2025


#63975: wp_delete_auto_drafts passes post ID as string instead of as int
-------------------------------------------------+-------------------------
 Reporter:  kkmuffme                             |       Owner:  kkmuffme
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Posts, Post Types                    |     Version:  3.4
 Severity:  trivial                              |  Resolution:
 Keywords:  has-patch changes-requested          |     Focuses:
  reporter-feedback                              |
-------------------------------------------------+-------------------------
Changes (by westonruter):

 * keywords:  has-patch changes-requested => has-patch changes-requested
     reporter-feedback


Comment:

 I can confirm that `$wpdb->get_col( "SELECT ID FROM $wpdb->posts" )`
 returns `string[]`, so it does make sense to cast this to an `int`.

 Nevertheless, I'm not sure where the fatal error is coming from.

 The `wp_delete_post()` function doesn't have any PHP type hint at all.

 The function signature is

 {{{#!php
 <?php
 function wp_delete_post( $post_id = 0, $force_delete = false ) {}
 }}}

 As I understand, a fatal error would only occur if strict types were
 declared and the function signature was:

 {{{#!php
 <?php
 function wp_delete_post( int $post_id = 0, bool $force_delete = false ) {}
 }}}

 However, given the current lack of any PHP type hints, I don't see how a
 fatal error would occur at present. PHP doesn't apply type hints defined
 in phpdoc. See https://3v4l.org/0L4Ru

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63975#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list