Make WordPress Core

Changes between Initial Version and Version 44 of Ticket #55942

04/26/2023 11:44:55 PM (13 months ago)


  • Ticket #55942

    • Property Focuses performance added
    • Property Component changed from Database to Options, Meta APIs
    • Property Summary changed from Add a "type" field to the meta and options tables to Add a "value type" parameter to get_option() and get_metadata()
    • Property Milestone changed from Future Release to 6.3
    • Property Keywords has-patch has-unit-tests needs-testing added
  • Ticket #55942 – Description

    initial v44  
    1 The idea to add a `type` or `format` field to all meta and options tables is not new, has been "floating around" for years. The general idea it that if some data is (automatically) serialized before saving to the DB, it will be (automatically) unserialized after retrieving it based on the value of the new field. This will make the `maybe_unserialize()` and `is_serialized()` functions pretty much redundant when retrieving data from these tables. It will also improve the performance and stability.
     1Update: This ticket had to be somewhat repurposed as it became clear that with the initial approach there's no good way to ensure full backwards compatibility in `get_option()` and `get_metadata()`.
    3 The new field can be very small. Seems that a `TINYINT` (requires only 1 byte of storage) would work there. Can also be something like `VARCHAR(20)` that may eventually prove more useful in the future, but perhaps the increase in size would not be worth it.
     3The initial idea to support "strict" types of the options and meta values remains the same, but the implementation has changed. The new approach is to add another parameter to the above functions. This would ensure 100% backwards compatibility and at the same time will provide approximately the same benefits:
     5- Consistent types of the return values from `get_option()`, `get_metadata()`.
     6- Reduced use of `maybe_unserialize()` and `is_serialized()`.
     8The main differences are that the new approach is opt-in and doesn't require new table columns.