Support » Plugins and Hacks » Add_post_meta incorrectly storing arrays

Add_post_meta incorrectly storing arrays

Viewing 6 replies - 1 through 6 (of 6 total)
  • But both of your strings are, well, strings. That’s kinda what ‘serialize’ does. Do your values not unserialize correctly?

    Right. I realize they’re both strings – but the first doesn’t unserialize correctly, while the second one does.

    Ok. I just inserted three different arrays with add_post_meta and none of them followed the ‘s:’ pattern. I don’t think it is WP, at least not a default install of WP.

    Serialize, in my experience, is squirrelly. So…

    1) Try with all of your plugins disabled.

    2) What does your array look like? Do print_r($yourarray);, view source, copy the array, and paste it here if its short or in the pastebin if its long. Do this right before you give the array to add_post_meta.

    3) Copy the whole serialized array from the database and paste it here if its short or in the pastebin if its long.

    Hm…. You’re right – I tried it on a clean install and no issues. Now to track down the culprit….

    Ugh… I ran into this too, but a clean install wasn’t really a feasible option. I ended up just bypassing post meta functions (get_post_meta, add_post_meta, update_post_meta), and instead doing straight queries with the $wpdb object… seems to have done the trick, but I’d really like to know what was causing the strange serialization issues…

    update_metadata () function, so that makes it appropriate serialized, update_post_meta () is okay to pass the data is not serialized.


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add_post_meta incorrectly storing arrays’ is closed to new replies.
Skip to toolbar