[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 01:48:52 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:
-----------------------------------------+------------------------------
Comment (by kkmuffme):
Replying to [comment:10 SirLouen]:
> Replying to [comment:9 kkmuffme]:
> > This is wrong. INT (or BIGINT) is always a (numeric-)string when using
mysql in PHP on unix.
>
> It's technically wrong (hence your strict typing alert or probably most
static analyzers), but not conceptually wrong given that this is only
going to receive an array of a very particular case of numerical strings
that happen to be simplistically incremental and mandatory BIGINT IDs, so
it's impossible that this can possibly fail.
Conceptually is irrelevant though, if this results in a fatal error, if
some do_action in the delete function are documented with @param int but
then provided a string type.
It might not be the do_action callback itself (since WP doesn't have
strict_types set), but if the callback function calls another function,
which expects an int, then you'll have a fatal too.
> Being sincere, I'm sure of what the general opinion is on these topics;
there are probably a couple hundred like this (and they will keep rising
as this is not strongly typed). I'm going to raise it in the next dev
chat, would like to hear from others.
With PHP natively supporting most phpdoc types as native type hints,
starting with PHP 7.1 but essentially full support with PHP 8.3+, phpdoc
annotations will become less relevant and type hints more common.
Therefore this is something that should be addressed and fixed in WP core
to ensure that at least action/filter annotations are correct and the type
specified is actually the type provided.
From my tests, there don't seem to be 100s like those, but only very few
action/filter annotations where it's actually wrong, and I also don't
think it's necessary to fix them all at once but just as they get
reported.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63975#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list