Support » Plugin: NS Cloner - Site Copier » Blog id not getting replaced.

  • Resolved vaibhav3

    (@vaibhav3)


    It seems that blog id is not getting replaced now with newer versions. (I just updated from 3.0.8 to the latest version).

    In 3.0.8, the upload_path in wp_options, blog_ID was getting replaced appropriately to new blog ID after cloning. Now, in the newer version, it doesn’t

    Using WordPress 4.9.8.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Never Settle

    (@neversettle)

    Hi @vaibhav3, could you check the “Enable logging” option and send us a copy of your resulting debug log at support@neversettle.it?

    Thread Starter vaibhav3

    (@vaibhav3)

    Hi,

    Any specific part or something?. That data is too sensitive to be given.

    Thanks,
    Vaibhav.

    Plugin Author Never Settle

    (@neversettle)

    Hi Vaibhav,

    Typically we need to see the whole log to be able to really understand what’s going on, but reading your post again I notice that it’s the upload_path option you’re referring to, which in normal configuration of WP multisite is not supposed to contain the blog id at all, because WP automatically adds it.

    We actually fixed a bug recently that was resulting in the upload_path option getting updated when it shouldn’t have, but it sounds like in your case the bug was actually helpful (guessing maybe you have a pre-3.5 ms-files type uploads storage in place, or some custom structure in play?).

    We can’t really change it back because it would re-introduce the first bug which is the more common case (typically upload_path shouldn’t vary between multisite blogs), but you could use the following filter if desired that would re-enable replacements on the upload_path when cloning:

    add_filter( 'ns_cloner_do_search_replace', function( $do, $row ) {
    	// If cloning the upload_path option in the options table, perform search/replace.
    	if ( $isset( $row['option_name'] ) && 'upload_path' === $row['option_name'] ) {
    		$do = true;
    	}
    	return $do;
    } );
    Thread Starter vaibhav3

    (@vaibhav3)

    Hi,

    Thanks for your inputs. I thought it to be a bug, so reported it. Anyways, I fixed this issue by following piece of code. I guess this should work as well or would have any other issues I’m unware of.

    add_action('ns_cloner_process_exit','fix_ns_cloner_path_fuction');
    function fix_ns_cloner_path_fuction() {
        /**
         * Get the request details.
         */
        $request    = ns_cloner_request()->get_request();
        /**
         * Get the path and new store ID.
         */
        $directory     = $request['target_upload_dir_relative'];
        $new_site_id   = $request['target_id'];
        /**
         * Switch to blog and update id
         */
        switch_to_blog($new_site_id);
        update_option('upload_path',$directory);
        restore_current_blog();
        return;
    }
    Plugin Author Never Settle

    (@neversettle)

    Great, glad you found a solution that works for you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.