Skip to content

Commit 6bfbc21

Browse files
committed
Use a boolean transient for has_multiple_admins.
1 parent 1692083 commit 6bfbc21

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

includes/Core/Authentication/Has_Multiple_Admins.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Has_Multiple_Admins {
2929
/**
3030
* The option_name for this transient.
3131
*/
32-
const OPTION = 'googlesitekit_has_multiple_admins';
32+
const OPTION = 'googlesitekit_has_multiple_administrators';
3333

3434
/**
3535
* Transients instance.
@@ -70,20 +70,18 @@ public function register() {
7070
* @return boolean TRUE if the site kit has multiple admins, otherwise FALSE.
7171
*/
7272
public function get() {
73-
$admins_count = $this->transients->get( self::OPTION );
73+
$has_multiple_admins = $this->transients->get( self::OPTION );
7474

75-
if ( false !== $admins_count ) {
76-
return $admins_count > 1;
75+
if ( false !== $has_multiple_admins ) {
76+
return 1 === $has_multiple_admins;
7777
}
7878

7979
if ( is_multisite() ) {
8080
$super_admins = get_super_admins();
8181
// If there are multiple super admins, we definitely have multiple admins.
8282
if ( count( $super_admins ) > 1 ) {
8383
$admins_count = count( $super_admins );
84-
// There's no need to check local admins in this case, although we should be aware that
85-
// the cached value may not include local admins.
86-
// We should consider making the cached value a boolean to avoid this ambiguity.
84+
// There's no need to check local admins in this case.
8785
} else {
8886
// If there is 0 or 1 super admin, we need to check local admins.
8987
// We exclude the super admin from the local check to avoid double counting
@@ -118,9 +116,11 @@ public function get() {
118116
$admins_count = $user_query->get_total();
119117
}
120118

121-
$this->transients->set( self::OPTION, $admins_count, WEEK_IN_SECONDS );
119+
$has_multiple_admins = $admins_count > 1 ? 1 : 0;
122120

123-
return $admins_count > 1;
121+
$this->transients->set( self::OPTION, $has_multiple_admins, WEEK_IN_SECONDS );
122+
123+
return $has_multiple_admins;
124124
}
125125

126126
/**

0 commit comments

Comments
 (0)