Commit 1073bcb2 authored by Kenneth Hall's avatar Kenneth Hall

Merge branch 'issue#3696' into 'develop'

fixes issue #3696 for multi-site issues

Closes #3696

See merge request ninja-forms/ninja-forms!3663
parents 0a698684 7e30211b
......@@ -37,7 +37,17 @@ class NF_Database_Migrations
}
}
public function nuke( $areYouSure = FALSE, $areYouReallySure = FALSE )
/**
* This function drops ninja forms tables and options
*
* @param $areYouSure
* @param $areYouReallySure
* @param $nuke_multisite
*
* @since 2.9.34
* @updated UPDATE_VERSION
*/
public function nuke( $areYouSure = FALSE, $areYouReallySure = FALSE, $nuke_multisite = TRUE )
{
if( ! $areYouSure || ! $areYouReallySure ) return;
......@@ -47,13 +57,18 @@ class NF_Database_Migrations
$this->_nuke();
return;
}
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
foreach( $blog_ids as $blog_id ){
switch_to_blog( $blog_id );
// adding this to make sure we don't nuke ALL subsites when upgrading one subsite
if ( $nuke_multisite ) {
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
foreach( $blog_ids as $blog_id ){
switch_to_blog( $blog_id );
$this->_nuke();
restore_current_blog(); // Call after EVERY switch_to_blog().
}
} else {
$this->_nuke();
restore_current_blog(); // Call after EVERY switch_to_blog().
return;
}
}
......
......@@ -6,7 +6,11 @@ function ninja_forms_ajax_migrate_database(){
if ( ! isset( $_POST[ 'security' ] ) ) return;
if ( ! wp_verify_nonce( $_POST[ 'security' ], 'ninja_forms_upgrade_nonce' ) ) return;
$migrations = new NF_Database_Migrations();
$migrations->nuke( true, true );
$sure = true;
$really_sure = true;
$nuke_multisite = false;
$migrations->nuke( $sure, $really_sure, $nuke_multisite );
$migrations->migrate();
echo json_encode( array( 'migrate' => 'true' ) );
wp_die();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment