[wp-trac] [WordPress Trac] #63975: wp_delete_auto_drafts passes post ID as string instead of as int
WordPress Trac
noreply at wordpress.org
Thu Sep 18 08:37:36 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 needs-test-info |
-------------------------------------------------+-------------------------
Changes (by kkmuffme):
* keywords: has-patch changes-requested reporter-feedback needs-test-info
close => has-patch changes-requested reporter-feedback needs-test-info
Comment:
Sorry guys, you're both WP core contributors and I have to explain PHP
basics we've covered in static analysis almost 10 years ago and with php-
src type hints for string/int type with strict types also more than half a
decade at this point.
Then claiming
>these kinds of theoretical reports
just is the cherry on top.
The gatekeeping in WP core is worse than in many corporate jobs at this
point and is quite different from what my experience with WP core in the
past.
I guess that's a side-effect of having to check that pineapple is
delicious on pizza when logging in, ensuring that sanity stays out the
door (just kidding)
Anyway, here's a simple reproduction - which in fact you can use for all
future reports reporting similar issue. Because the reproduction will
always be the same, no matter the hook. You only need to change the type
hint.
As you can see, this has nothing to do with static analysis.
{{{#!php
<?php
declare(strict_types=1);
function foo( $post_id ) {
bar( $post_id );
}
add_action( 'before_delete_post', 'foo' );
function bar( int $post_id ): void {}
wp_delete_post( '1' );
}}}
For non-scalar type hints, this is a fatal even without strict_types=1
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63975#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list