mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Multisite: Use get_network()
in populate_network()
to check whether a network with the given ID already exists.
When multisite is setup already, e.g. in a multi network environment, this change gives a performance benefit over the direct SQL query that was previously used. The SQL query remains in place for when setting up multisite initially as the network API is not available at that point. Props spacedmonkey. Fixes #41805. Built from https://develop.svn.wordpress.org/trunk@41348 git-svn-id: http://core.svn.wordpress.org/trunk@41181 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2bd20bb0db
commit
6ced176459
@ -905,8 +905,16 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||
$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );
|
||||
|
||||
// Check for network collision.
|
||||
if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) )
|
||||
$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
|
||||
$network_exists = false;
|
||||
if ( is_multisite() ) {
|
||||
if ( get_network( (int) $network_id ) ) {
|
||||
$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
|
||||
}
|
||||
} else {
|
||||
if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) {
|
||||
$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! is_email( $email ) )
|
||||
$errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) );
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-alpha-41347';
|
||||
$wp_version = '4.9-alpha-41348';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user