From b47cf7330cbbdd17e924184094c240c0150549ab Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Mon, 2 Oct 2017 03:06:47 +0000 Subject: [PATCH] Multisite: Use `get_networks()` instead of a direct query in `get_admin_users_for_domain()`. Props spacedmonkey. Fixes #41806. Built from https://develop.svn.wordpress.org/trunk@41664 git-svn-id: http://core.svn.wordpress.org/trunk@41498 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-deprecated.php | 13 ++++++++++--- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/wp-includes/ms-deprecated.php b/wp-includes/ms-deprecated.php index 8470a12b96..cba5f1e57b 100644 --- a/wp-includes/ms-deprecated.php +++ b/wp-includes/ms-deprecated.php @@ -429,10 +429,17 @@ function get_admin_users_for_domain( $domain = '', $path = '' ) { global $wpdb; - if ( ! $domain ) + if ( ! $domain ) { $network_id = get_current_network_id(); - else - $network_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path ) ); + } else { + $_networks = get_networks( array( + 'fields' => 'ids', + 'number' => 1, + 'domain' => $domain, + 'path' => $path, + ) ); + $network_id = ! empty( $_networks ) ? array_shift( $_networks ) : 0; + } if ( $network_id ) return $wpdb->get_results( $wpdb->prepare( "SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $network_id ), ARRAY_A ); diff --git a/wp-includes/version.php b/wp-includes/version.php index d32e4e407c..6c9a9eb279 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41663'; +$wp_version = '4.9-alpha-41664'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.