[wp-trac] [WordPress Trac] #55942: Add a "type" field to the meta and options tables
WordPress Trac
noreply at wordpress.org
Sat Mar 11 01:19:40 UTC 2023
#55942: Add a "type" field to the meta and options tables
-------------------------------------------------+-------------------------
Reporter: azaozz | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future
| Release
Component: Database | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests needs- | Focuses:
testing | performance
-------------------------------------------------+-------------------------
Comment (by azaozz):
Replying to [comment:26 petitphp]:
> We already have a way to define the type of data when using
`register_meta`/`register_term_meta`/`register_setting`.
Right, although it's a bit "weird" :)
Apparently the data types in the REST API are defined as `'string',
'boolean', 'integer', 'number', 'array', and 'object'`, see
https://core.trac.wordpress.org/changeset/39222#file1, [40603], and
[46186]. Then the data types for `register_meta()` were copied, and ended
up being a bit incompatible with PHP.
A `number` is not a valid data type in PHP, seems it corresponds to
`float`, a.k.a. `double`.
> We could leverage this to handle saving/retrieving data from the
database
Yep, should be able to. Just need to add some code to "juggle" `number`
<=> `float` for the REST API.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55942#comment:29>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list