@@ -116,15 +116,21 @@ public function get($uid) {
116116 if (is_null ($ uid ) || $ uid === '' || $ uid === false ) {
117117 return null ;
118118 }
119- if (isset ($ this ->cachedUsers [$ uid ])) { //check the cache first to prevent having to loop over the backends
120- return $ this ->cachedUsers [$ uid ];
121- }
122119
123120 if (strlen ($ uid ) > IUser::MAX_USERID_LENGTH ) {
124121 return null ;
125122 }
126123
124+ // check the cache first to prevent having to loop over the backends
125+ if ($ excludeBackends === [] && isset ($ this ->cachedUsers [$ uid ])) {
126+ return $ this ->cachedUsers [$ uid ];
127+ }
128+
127129 $ cachedBackend = $ this ->cache ->get (sha1 ($ uid ));
130+ if (in_array ($ cachedBackend , $ excludeBackends )) {
131+ $ cachedBackend = null ;
132+ }
133+
128134 if ($ cachedBackend !== null && isset ($ this ->backends [$ cachedBackend ])) {
129135 // Cache has the info of the user backend already, so ask that one directly
130136 $ backend = $ this ->backends [$ cachedBackend ];
@@ -139,6 +145,10 @@ public function get($uid) {
139145 continue ;
140146 }
141147
148+ if (in_array ($ i , $ excludeBackends )) {
149+ continue ;
150+ }
151+
142152 if ($ backend ->userExists ($ uid )) {
143153 // Hash $uid to ensure that only valid characters are used for the cache key
144154 $ this ->cache ->set (sha1 ($ uid ), $ i , 300 );
@@ -187,7 +197,7 @@ public function userExists($uid) {
187197 return false ;
188198 }
189199
190- $ user = $ this ->get ($ uid );
200+ $ user = $ this ->get ($ uid, $ excludeBackends );
191201 return ($ user !== null );
192202 }
193203
0 commit comments