bobbingwide / oik-clone

Clone content between sites
https://www.oik-plugins.com/oik-plugins/oik-clone-clone-your-wordpress-content/
GNU General Public License v2.0
5 stars 0 forks source link

Warning: cloning Row core/group block #66

Open bobbingwide opened 2 years ago

bobbingwide commented 2 years ago

Warning: foreach() argument must be of type array|object, bool given in C:\apache\htdocs\wordpress\wp-content\plugins\oik-clone\admin\class-oik-clone-relationships.php on line 81

Appeared twice when cloning

https://blocks.wp.a2z/block/group-core-group/row-core-group/

WordPress 5.9-RC3, Gutenberg 12.3.0

bobbingwide commented 2 years ago

I got the same message cloning https://blocks.wp.a2z/block/group-core-group/ WordPress 5.9.1, Gutenberg 12.6.0

bobbingwide commented 2 years ago

And again with WordPress 5.9.3 and Gutenberg 12.9.0

bobbingwide commented 2 years ago

This problem could be because in the source system the Block CPT was set to hierarchical but in the target it's not. In blocks.wp.a2z the post_name slugs for both the Group block and the Group variation are the same:

https://blocks.wp.a2z/group-core-group https://blocks.wp.a2z/block/group-core-group/group-core-group

When the variation was cloned it was cloned to the same post as its parent. The fix requires the clone ids metadata ( meta_key _oik_clone_ids ) to be removed.

There's another problem here. The link to the main block is missing the /block part of the permalink. That would appear to be a problem with oik-blocks code for the blocklist block.

bobbingwide commented 2 years ago

The fix requires the clone ids metadata ( meta_key _oik_clone_ids ) to be removed.

I wrote a utility routine to delete the post meta data. This didn't resolve the problem. The wrong post is chosen when the child post is being cloned. The workaround could be to set a numerically suffixed slug on the child post.

Setting a suffix in the post name for the variation didn't resolve the problem for the link to the variation, which was still https://blocks.wp-a2z.org/block/group-core-group/group-core-group but it did resolve the problem with not being able to find the variation for the shortcode [blocks core/group:group]

It didn't fix the Warning messages either.