Skip to content

Commit

Permalink
Ensure site caches are primed.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc committed Jan 14, 2024
1 parent 81604ed commit 940162a
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,11 @@ public static function build_available_authorized_sites( $user_id = false, $cont
/*
* get_blogs_of_user() returns sites in a different shape to get_sites().
*
* This gets each of the sites in the correct shape, get_site() is called for each
* site individually as the sites will each be cached so this is more performant
* than using get_sites().
* To avoid an additional query, the cache for the site IDs is primed and then
* get_site() is used to retrieve the site object. This prevents an unnecessary
* query in get_sites().
*/
_prime_site_caches( $user_site_ids );
foreach ( $user_site_ids as $user_site_id ) {
$user_site = get_site( $user_site_id );

Expand Down

0 comments on commit 940162a

Please sign in to comment.