[wp-trac] [WordPress Trac] #52298: Using ID as type string instead of int
WordPress Trac
noreply at wordpress.org
Thu Jan 14 21:54:13 UTC 2021
#52298: Using ID as type string instead of int
-------------------------------+----------------------
Reporter: malthert | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: General | Version:
Severity: normal | Resolution: wontfix
Keywords: reporter-feedback | Focuses:
-------------------------------+----------------------
Comment (by malthert):
>Changing this would break every plugin and theme that uses strict types
or strict comparison (===).
If you take a look at what is around in the WP ecosystem (plugins), this
is handled so inconsistently that even add filters often change the ID to
type string (due to missing typecasting).
Given your reasoning, all these inconsistent implementations would break
every plugin.
>A post ID is an integer. It's a BIGINT in the database. It's typecast
internally because it's read from the database as a string, which is
unfortunate, but that ship sailed fifteen years ago.
I totally agree with you on this. The issue however is handling. The
majority of plugins do not typecast their IDs/data they retrieve from
wpdb, option, transient or cache (which ALL return type string) causing an
idiotic mix of string|int.
Thus why not make it simple for everybody and switch it to string - as
lots (probably most) plugins already treat it as a string anyway, since
they (almost) never typecast their stuff.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52298#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list