[wp-trac] [WordPress Trac] #55942: Add a "type" field to the meta and options tables

WordPress Trac noreply at wordpress.org
Tue Jun 7 20:00:48 UTC 2022


#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:               |     Focuses:
-------------------------+-----------------------------

Comment (by azaozz):

 There are (at least) three ways this could be implemented:

 1. The most basic: `0` would be default and undefined, `1` would mean the
 data was not serialized when storing it, `2` would mean thew data was
 serialized.

 2. A better way would be to store the primitive (basic) PHP types: `0`
 would be default and unset, 1 would be boolean, 2 would be int, 3 would be
 float, 4 would be string, etc.
 (https://www.php.net/manual/en/language.types.intro.php). Then the data
 can be type-casted after retrieving it form the DB. This will also
 improve/fix one of the long-standing problems with saving a specific type
 to the DB but retrieving it as a different type, like saving bool `false`
 but getting string `'0'`.

 3. If a `VARCHAR` is used the new field can store the actual name of the
 type: ` bool`, `int`, `float`, etc. and perhaps plugins would be able to
 add their own custom types. However not so sure that would be useful at
 such a low level, and it will increase the complexity (and perhaps the
 need for maintenance), and the overall tables size quite significantly.

 Moving this to the 6.1 milestone for consideration.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55942#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list