WordPress.org

Ideas

Store options as JSON instead of serialized data to make search and replace safe

  1. Nick Ciske
    Member

    12345

    Doing a search and replace (e.g migrating domains) breaks serialized data. There are workarounds, but a core change to using JSON to store options would fix the issue for good.

    Even some filters or a constant to allow devs to switch the format would be a workable solution.

    Posted: 5 years ago #
  2. Gustavo Bordoni
    Inactive

    Once I've asked the same, and I've got an answer.

    It's because of the Variables Types, that the serialization can hold the type and JSON has some problems with that.

    Posted: 5 years ago #
  3. Klaus
    Inactive

    12345

    Yes, JSON does have some type-issues regarding PHP, but only on the object-level.

    It is much faster to encode and decode and it's lesser pain for replace-functions.

    +1

    Posted: 2 years ago #
  4. Ipstenu (Mika Epstein)
    Lead Plugin Wrangler

    WP-cli and the popular interconnectit script both handle serialization safe search and replace

    https://github.com/interconnectit/Search-Replace-DB

    I would worry more about the cost of changing the databases for large sites in this sort of change. Any major DB change has the potential to crash a large site on upgrade and must be done carefully.

    Posted: 2 years ago #
  5. Klaus
    Inactive

    12345

    I know those tools - they are great.

    But still the performance with JSON is better most of the time.

    Migration can be handled if it is some sort of a rolling change. A lot of plugins write their stuff as serialized data (onto different tables) too...

    Posted: 2 years ago #
  6. Nick Ciske
    Member

    12345

    I can’t even imagine how many plugins this would break (witness something as simple as a security patch requiring plugins to actually use the official shortcode api vs. hack around it and the hubbub around that), so I've given up on it ever happening.

    Short of a rewrite of how options work (and/or maybe a switch to support Postgre SQL which has a JSON column type) -- one can dream?

    http://www.postgresql.org/docs/9.3/static/datatype-json.html

    The serialization "issue" is basically a non-issue these days with the multitude of "serialization safe" tools available.

    Posted: 2 years ago #
  7. Ipstenu (Mika Epstein)
    Lead Plugin Wrangler

    Migration can be handled if it is some sort of a rolling change. A lot of plugins write their stuff as serialized data (onto different tables) too...

    Yeaaaah that's a different kettle of fish :)

    I was thinking of just the hassle with WP Core. God help us when we get to plugins.

    Nick - Actually very few plugins with bad shortcodes broke.

    It is therefore not possible for JSON to conform rigidly to the specification unless the server encoding is UTF-8.

    THAT would be a problem.

    Posted: 2 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    2 Votes
  • Status

    Sorry, not right now