[wp-trac] [WordPress Trac] #55942: Add a "value type" parameter to get_option() and get_metadata()

WordPress Trac noreply at wordpress.org
Thu May 11 17:48:13 UTC 2023


#55942: Add a "value type" parameter to get_option() and get_metadata()
--------------------------------+--------------------------
 Reporter:  azaozz              |       Owner:  (none)
     Type:  enhancement         |      Status:  new
 Priority:  normal              |   Milestone:  6.3
Component:  Options, Meta APIs  |     Version:
 Severity:  normal              |  Resolution:
 Keywords:  2nd-opinion         |     Focuses:  performance
--------------------------------+--------------------------

Comment (by knutsp):

 Replying to [comment:78 knutsp]:
 > 1. Reduce calls to `maybe_unserialize()` when type is explicitly a
 scalar type.
 > 2. No costly database table restructuring
 > 3. Saved typing by default, first phase PHP types only, second phase
 maybe allow/respect [ 'scalar', 'numeric', 'number', 'serialized', 'json',
 ...]
 > 4. Saved typing can be opted out for special cases or som kind of
 extended backwards compatibility.
 > 5. Should work with centralized registering of sanitizing, validation
 and UI/HTML handling, as saving with type this takes precedence on save,
 registered handling takes precedence on read/returning values.
 > 6. No new/alternative functions for centralized registering
 > 7. Future scope as 3. above, plus opens for even other serialization
 methods (CSV maybe?) and even compression.

 I made a plugin to demonstrate. Se file `functions.php` for mye idea for
 the typing logic and saving. I also propose to base canonical type naming
 on `get_debug_type()` in PHP 8. This can be polyfilled.
 https://github.com/knutsp/core-ticket-55942

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


More information about the wp-trac mailing list