[wp-trac] [WordPress Trac] #63975: wp_delete_auto_drafts passes post type as string instead of as int
WordPress Trac
noreply at wordpress.org
Mon Sep 15 11:03:26 UTC 2025
#63975: wp_delete_auto_drafts passes post type 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:
-----------------------------------------+------------------------------
Changes (by SirLouen):
* keywords: has-patch => has-patch changes-requested
* owner: (none) => kkmuffme
* version: => 3.4
* status: new => assigned
Comment:
@kkmuffme how have you detected this?
Are you passing some level of PHPStan/psalm or something?
`$old_posts` receives an array of post ID, which, according to the
database table definition, have to be `int` (BIGINT) forcefully. So strong
typing is good for quality purposes, but code is plagued with these.
What is weirder for me, is the force conversion to an array of
`$old_posts` as `get_col` is always an array according to the phpdoc
definition. But you will know definitely that the array values will be int
always. So I would remove the `(array)` and add the `(int)` just to force
typing, although its not strictly necessary (WP overall is not strongly
typed, and common sense among data structures take a lot of place).
For context: This was built in [20453]/#19663, there are no design
decisisons of why this `(array)` or this absence of `(int)`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63975#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list