Make WordPress Core

Changeset 40406


Ignore:
Timestamp:
04/10/2017 09:59:59 PM (8 years ago)
Author:
flixos90
Message:

Multisite: Replace unnecessary is_super_admin() check when setting up the initial network.

When using is_super_admin() in a non-multisite environment, the function is supposed to check for administrator capabilities. The process of querying all users and filtering them with that function can be optimized by only querying users with the administrator role instead.

Fixes #40406. See #37616.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/schema.php

    r39709 r40406  
    952952    if ( !is_multisite() ) {
    953953        $site_admins = array( $site_user->user_login );
    954         $users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) );
     954        $users = get_users( array(
     955            'fields' => array( 'user_login' ),
     956            'role'   => 'administrator',
     957        ) );
    955958        if ( $users ) {
    956959            foreach ( $users as $user ) {
    957                 if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) )
    958                     $site_admins[] = $user->user_login;
     960                $site_admins[] = $user->user_login;
    959961            }
     962
     963            $site_admins = array_unique( $site_admins );
    960964        }
    961965    } else {
Note: See TracChangeset for help on using the changeset viewer.