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

WordPress Trac noreply at wordpress.org
Fri Oct 21 17:21:25 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:  has-patch has-unit-tests needs-      |     Focuses:
  testing                                        |  performance
-------------------------------------------------+-------------------------

Comment (by flixos90):

 I love the idea of this ticket, but I'm wary about how we can solve it in
 a backward compatible way while also not making the API super clunky. To
 me, the main concern here is that plugins today may to do something like
 `get_option( 'some_boolean_ish_option' ) === '1'`, which could break
 following this change. To be clear, I would discourage anyone from writing
 code like that, but it's probably out there :)

 Similarly, for integer and float comparison, while it's already encouraged
 to always type-cast `get_option()` results, there are probably some
 plugins today that use either loose comparison (discouraged) or explicitly
 compare with a string (also discouraged), like `get_option( 'some_number'
 ) === '42'`.

 @azaozz Is your idea that the new type column value would be set based on
 the data passed to `add_option()` / `update_option()`, or based on the
 registered type of only registered settings?

 I wonder whether something like the latter could be used to make this more
 of an opt-in thing. Or alternatively we can see about a slow rollout,
 where we post about this in advance, potentially even send something about
 it in an email to plugin developers, and/or build checks to catch problems
 like the above into WPCS. Some of this may be a stretch, but let's see :)

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


More information about the wp-trac mailing list