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

Update MultiSite pull logic for attachments #29

Closed bobbingwide closed 3 years ago

bobbingwide commented 5 years ago

The MultiSite pull logic does not handle attachments correctly. The attached file is not copied and the resulting URL is wrong. This can lead to a 500 internal error e.g. After copying from woocommerce.wp.a2z into blocks.wp.a2z the URL for the WooCommerce icon was set to

https://blocks.wp.a2z/wp-content/uploads/sites/10/2016/04/woocommerce-icon-256x256-1.png

but the file did not exist.

Copying the file manually didn't seem to resolve the problem. Probably due to _wp_attachment_metadata being wrong/missing.

bobbingwide commented 5 years ago

oik_clone_attachment_file() needs to create the directory for the target file otherwise you get a strange message from PHP.

Warning: copy(
C:\apache\htdocs\wp-a2z/wp-content/uploads/sites/10/2016/07/wordpress-core-icon-256x256.jpg):
failed to open stream: 
No such file or directory in 
C:\apache\htdocs\wordpress\wp-content\plugins\oik-clone\tests\test-php-copy.php on line 9

It's not at all obvious since the file name given in the message is the target file name. If there was a problem with the source file you'd see the same message but with the invalid source file name.

Solution: mkdir( dirname( $target )) before the copy(). but you also need to check that the folder doesn't already exist.

bobbingwide commented 5 years ago

The oik-clone admin page does not list all the attachments... only those which are not attached.

bobbingwide commented 3 years ago

oik-clone v2.0.0 has been released. Closing this issue.