• Hi,

    Metadata for revisions is being collapsed into a serialised object, rather than kept in the same format as on the main post object.
    This appears to be by design?

    I’m not sure of the rationale for this; I’m guessing it’s an attempt to reduce the number of metadata rows, though in practice it’s likely to not have much effect as probably most meta keys aren’t multiples (at least in my experience).

    However, this has a significant impact on the ability to use that data, as once serialised, it can’t be queried sensibly in SQL / wp_query, and must be deserialised before being used. It’s a general rule to avoid storing serialised data in a DB whenever possible, as it means queries can’t be done quickly in SQL, and all rows must be returned, deserialised, and the query run in code, which has many disadvantages.

    In my case, I need to show historical versions of the metadata via the front-end, and I don’t want to have two versions of code to de-serialise the data if it’s a revision, it’s more logic to maintain and test. It also prevents queries on historical versions via SQL.

    For my use, I’ve replaced this by code to copy the revisioned metadata from the post to revision exactly as it is on the parent post.
    I suggest you adopt this approach for the plugin, as there seems to be no benefit and many drawbacks to the approach taken. Should this make it into WP core, it seems it’d be a very bad move.

    So, getting to the question: is there any reason why this approach was taken, and can you switch to preserving the metadata in the same format it currently is?

  • The topic ‘Revision metadata being collapsed into serialised objects’ is closed to new replies.