WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Images Not Cloning

[Resolved] Images Not Cloning

  • canheread7
    Member

    @canheread7

    Hello, First thank you for the plugin it is exactly what my company needs! I am on a sub-directory network on WordPress 3.5 and the sites are being cloned perfectly but none of the images are being transfered along with the new site. Is there something I should be trying differently or is this a known bug?

    Thank you so much for your time

    http://wordpress.org/extend/plugins/ns-cloner-site-copier/

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Never Settle
    Participant

    @neversettle

    Thanks for the feedback!!! We have seen this issue in some cases but haven’t pinpointed the cause yet. It’s possible that the file copy failed because of folder permissions. You might be able to manually copy the contents of /wp-content/blogs.dir/ID-1 to /wp-content/blogs.dir/ID-2 where ID-1 is the source site ID and ID-2 is the target (new) site ID.

    Once the files are copied over, it’s hopeful that the images will come up as the database itself should be correctly pointing to the new directory. Please let us know if this works for you as it will help us isolate the cause.

    Thank you!

    canheread7
    Member

    @canheread7

    Thanks for the fast response! Rest assured if we can get this fixed in the next few days my company would love to be “Pro Members” of your plugin and support you all anyway we can. Here is what I have found so far:

    I got the IDs of each site out of the URL when viewing the details of the specific site from the network page. FTPing into my site I found that neither the template site nor the copied site had folders in wp-content/blogs.dir/[ID] and of the sites that did have folders in them only one had any content other than just directories…

    BUT!!

    I did find the content in wp-content/uploads/sites/[ID] and when I copied the contents from the template to the child it worked perfectly! Is this a setting I can change to change where the files are stored or is there some sort of workaround I can implement in the meantime? Please let me know if there is anything else I can do or try.

    Thanks a lot!!

    Plugin Author Never Settle
    Participant

    @neversettle

    Interesting! Normally all files in multisite are supposed to get uploaded to the correct /blogs.dir/ID subdirectory per site, which is what the cloner targets for the file copy when it is cloning a site. But it turns out that WP 3.5 changed this location (although upgraded installs retain the old location). New installs of 3.5 now use something like /uploads/sites/ID (which is what you are seeing).

    Can you tell us – is this a new 3.5 multisite install or did you upgrade from a 3.4 or earlier multisite install? Either way, we’ll have to tweak the code to auto-detect the uploads location since it changed. I’m not sure how fast we can fix and test, but we’ll try to make it happen quickly as it will start affecting more and more sites that start out in 3.5 multisite. Thank you very much again for reporting it, and we’ll try to get it patched quickly as well as future-proof it a little more too.

    canheread7
    Member

    @canheread7

    It is a fresh 3.5 install. I did a find and replace (no disrespect) on your code from blogs.dir to uploads/sites and tried it a few times an everything transfered great! I know this is surely not a permanent fix and look forward to you all doing the update!

    Your has help has absolutely won my vote to your plugin!

    Keep up the good work!

    Plugin Author Never Settle
    Participant

    @neversettle

    Fantastic! That is quite fine – the beauty of WP and plugins like this is that you can implement your own work-arounds or tweaks as necessary. We fully support and encourage all those amazing benefits of open source. Input like yours also helps improve our work and drive a better end result for others. We’re working on a patch that will use the WP API to detect the uploads directory (even if someone has defined a custom location in wp-config.php). Appreciate everything!

    Would be awfully kind if you could share the solution? :)Same problem – images dont get copied.

    and yes, awesome plugin!

    OK, here is what you need to replace to

    ————————-
    ‘//build replacement array
    //new-site-specific replacements
    $replace_array[$source_subd] = $target_subd;
    $replace_array[$source_site] = $target_site;
    $replace_array[‘uploads/sites/’ . $source_id . ‘/’] = ‘uploads/sites/’ . $target_id . ‘/’;
    $replace_array[str_replace(‘ ‘, ‘%20’, $source_site)] = str_replace(‘ ‘, ‘%20’, $target_site);
    //reset the option_name = wp_#_user_roles row in the wp_#_options table back to the id of the target site
    $replace_array[$wpdb->base_prefix . $source_id . ‘_user_roles’] = $wpdb->base_prefix . $target_id . ‘_user_roles’;

    //replace
    $this->dlog ( ‘running replace on Target table prefix: ‘ . $target_pre . ‘
    ‘ );
    foreach( $replace_array as $search_for => $replace_with) {
    $this->dlog ( ‘Replace: <b>’ . $search_for . ‘</b> >> With >> <b>’ . $replace_with . ‘</b>
    ‘ );
    }
    $this->run_replace($target_pre, $replace_array);

    // COPY ALL MEDIA FILES
    $upload_dir = wp_upload_dir();
    $src_blogs_dir = str_replace(‘uploads’, ‘uploads/sites/’ , $upload_dir[‘basedir’]) . $source_id;
    $dst_blogs_dir = str_replace(‘uploads’, ‘uploads/sites/’ , $upload_dir[‘basedir’]) . $target_id;
    $num_files = recursive_file_copy($src_blogs_dir, $dst_blogs_dir, 0);
    $report .= ‘ and Copied: <b>’ .$num_files . ‘</b> folders and files!
    ‘;’
    ——————————————————

    dmcwhinnie2
    Member

    @dmcwhinnie2

    I am having the same issue, and maybe some more.

    Brand new 3.5.1 install, created a new site, then installed NS Cloner. There is nothing in my blog.dir folder, and when a site is cloned still nothing gets created here.

    Now when I clone the images in the media library are broken. The new folder exists, but the images are not copied.

    The new thing I noticed is that the cloned site still has the images embedded in the HTML from the original site in the generated pages.

    canheread7
    Member

    @canheread7

    I believe I was running into the same issue but did a temporary fix by bringing up the code for the plugin and replacing “blogs.dir” to “uploads/sites” so the the plugin looks for and copies content into that folder instead. Hopefully this helps!

    Plugin Author Never Settle
    Participant

    @neversettle

    Yes, thanks @canheread7 is correct.

    This is a known issue that we are still working on, with 3.5 installs and later, there was a change to how WP handles uploads in multisite and blogs.dir is no longer used. The entire uploads structure changed and it is a challenge to support both the old and the new versions, automatically replace all variations of the links in the clone so that the DB matches the file system, and make sure that predictive compatibility will be maintained in the future if it changes again – all in a single plugin. We’re hoping to have an update soon. Sorry for the inconvenience and thank you for your patience!

    Plugin Author Never Settle
    Participant

    @neversettle

    FYI we just released an update that should correct these issues and handle media file copies regardless of wordpress version or installation / upgrade history. Thanks!

    chrisnewell4444
    Member

    @chrisnewell4444

    Master Site = http://TheSeniorAgent.com
    Copied Site = http://template.thesenioragent.com/

    Images did not copy across during the clone, “blogs.dir” does not exist in wpcontent in original site but does in clone

    Thanks

    Plugin Author Never Settle
    Participant

    @neversettle

    Hiya! It looks like the images are there on the clone site now – did you manually copy them over? Or is there a page where they are still broken?

    If you can send us your logs under /wp-content/plugins/ns-cloner-site-copier/logs here: http://neversettle.it/support-and-feedback/ we’ll take a further look at what might be going on in your environment.

    Thanks!

    chrisnewell4444
    Member

    @chrisnewell4444

    Oh, sorry, I forgot to update. I had to copy the files for the 3 months since the site was created and also go in and re-upload the files that are part of the theme and re-place them.

    I will send the log files, as I don’t want to have to do that for every time I clone a site.

    Thanks

    chrisnewell4444
    Member

    @chrisnewell4444

    I don’t have the folder you referrenced. In the public_html, there is a ns-cloner-pro that has a log file dated today and in the public_html-mu there is a folder with log dated a month ago.

    I just did the clone today, and ended up copying the files from public_html to public_html-mu

    Please advise

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Resolved] Images Not Cloning’ is closed to new replies.