humanmade / post-cloner

Post Cloner plugin
3 stars 2 forks source link

CMB2 repeater/group field post meta isn't cloned correctly #17

Closed tareiking closed 4 years ago

tareiking commented 4 years ago

When testing with a fresh chassis stack and the example repeatable group from CMB2 - the post meta isn't cloned correctly from the parent -> cloned post.

Parent post meta in DB (key: yourprefix_group_demo)

a:1:{i:0;a:5:{s:5:"title";s:8:"clone me";s:11:"description";s:20:"clone me description";s:8:"image_id";i:643;s:5:"image";s:51:"http://altis.local/tchyn/uploads/2019/08/record.jpg";s:13:"image_caption";s:7:"caption";}}

Cloned post meta in DB (key: yourprefix_group_demo)

s:217:"a:1:{i:0;a:5:{s:5:"title";s:8:"clone me";s:11:"description";s:20:"clone me description";s:8:"image_id";i:643;s:5:"image";s:51:"http://altis.local/tchyn/uploads/2019/08/record.jpg";s:13:"image_caption";s:7:"caption";}}";

~It appears the cloned post meta key is converted to a string on post cloning, when it should remain an array in this case.~ Core runs through maybe_serialize when adding post meta. This checks if post meta is an option and serializes the key.

tareiking commented 4 years ago

@mikeselander - wondering if you could weigh in here. After finding the cause of said issue above, I'm not sure whether the core post-cloner plugin would/should support cloning post meta for CMB2 repeater fields.

Should we tackle fixing post meta on a project level, or is supporting CMB2 field cloning something to fix in this plugin itself?

Happy for you to close the issue if its a wontfix for the post-cloner plugin.