• Documentation
  • Support / Community
  • Products
    • Piklist Framework
    • Toolbox
    • Fields and Forms
    • WordPress Helpers
  • Log In
Piklist

Access your account, and post on the Support Forums

Retrieve Password | Register for account

Topic: maybe_serialize & double-serialization of post_meta values

Support Home » Topics » Piklist » maybe_serialize & double-serialization of post_meta values

Tagged: Database, post_meta

  • This topic has 5 replies, 2 voices, and was last updated 4 years, 8 months ago by Steve.
Viewing 5 reply threads
  • Author
    Posts
    • May 8, 2017 at 11:52 pm #8203
      hughc
      Member

      I’ve struck this issue twice recently; 2 sites running the Events Calendar one Pro.

      I’ve got corrupted post_meta values due to existing array data being double serialized.

      The error manifests in a 500 when trying to save an Event. The code dies because it has pulled a string out of the database when it expected an Array.

      my database values

      If I disable Piklist, Events save correctly.

      In browsing the issue, I read this: https://codex.wordpress.org/Function_Reference/maybe_serialize#Notes

      in includes/class-piklist-meta.php wp_save_post_revision_post_meta_serialize() looks like it does a maybe_serialize on raw values from the database, and then writes them back, without first checking whether the value is already serialized.


      @sbruner
      or @jasontheadams , when should this code be triggered?

      Without a clear understanding of when this is called, I can’t be certain that this is the cause. But I’ve definitely got a conflict between Piklist 0.9.9.9+ and the Events Calendar.

    • May 9, 2017 at 12:53 am #8204
      hughc
      Member

      FWIW, I commented out the relevant lines in wp_save_post_revision_post_meta_serialize() but the issue remains. There must be something else going on here.

    • May 9, 2017 at 10:30 am #8206
      Steve
      Keymaster

      @hughc–

      Two things to try:

      1) Under Piklist > Settings. Make sure “Accelerate meta queries” is NOT checked.
      2) Try our latest beta >

    • May 10, 2017 at 9:52 pm #8226
      hughc
      Member

      OK I think I’ve tracked this down.

      I’m using 1.1 beta2

      in Piklist_Revision there’s a save_post hook that appears to pull a raw value from the database, and then executes an add_metadata() with the value that’s extracted.

      Disable the hook, Events save.
      Enable the hook, I start seeing PHP Strings in the DB in place of Arrays and I get a 500 when saving Events.

      I added the following line @ line 56, before add_metadata():

      $object->meta_value = maybe_unserialize($object->meta_value);

      Values end up in the database, clean, and Events are saving OK.

      The only issue that I can see, at a database level, is that the metadata values are doubled up, but this may be a hangover from an original issue, where at some point duplicates were created and now values are being slavishly copied from one revision to another perpetuating the duplicates.

      What is the save_post hook trying to achieve? Transcription of piklist-specific values from one post revision to another?

    • May 22, 2017 at 2:29 am #8245
      hughc
      Member

      @sbruner should I be flagging this as a GitHub issue? I don’t want to pollute the bug list there unnecessarily.

      To be clear, I don’t have any Piklist-created metadata fields associated with the Events post type, but they don’t seem to play nice without the fix above in place.

    • May 22, 2017 at 9:52 am #8246
      Steve
      Keymaster

      @hughc– I think we’re going to use this support forum for .org bugs, and github for the beta bugs.

  • Author
    Posts
Viewing 5 reply threads
  • You must be logged in to reply to this topic.
Log In

Log in / Register

Register for an Account

Stay up-to-date with Piklist

About

  • Philosophy
  • Privacy Policy
  • Terms of Service
  • Contact Us
  • Register for an account

Resources

  • Community Forums
  • Documentation
  • Tutorials
  • Get involved

Follow Piklist

  • Like us on Facebook
  • Follow us on Twitter
  • Connect on Google +
  • Watch on YouTube

Rate Piklist


If you love Piklist leave us a 5 Star review on WordPress.org.

News

  • Piklist v0.9.9.8 is now available

    September 30, 2019

    In October of 2015, we released v0.9.9 of Piklist. Your help in testing lead to seven(7) m ...

  • Piklist is now on HackerOne

    September 30, 2019

    We built Piklist from the ground up with security as our top priority. While we’ve t ...

  • Read all News
  • Powered by Piklist & WordPress © 2009 – 2022 Piklist LLC.
    This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to the use of cookies. Find out more.