@@ -650,7 +650,7 @@ public function callForSeenUsers(\Closure $callback) {
650650 }
651651
652652 /**
653- * Getting all userIds that have a listLogin value requires checking the
653+ * Getting all userIds that have a lastLogin value requires checking the
654654 * value in php because on oracle you cannot use a clob in a where clause,
655655 * preventing us from doing a not null or length(value) > 0 check.
656656 *
@@ -828,19 +828,19 @@ public function getDisplayNameCache(): DisplayNameCache {
828828 return $ this ->displayNameCache ;
829829 }
830830
831- /**
832- * Gets the list of users sorted by lastLogin, from most recent to least recent
833- *
834- * @param int $offset from which offset to fetch
835- * @return \Iterator<IUser> list of user IDs
836- * @since 30.0.0
837- */
838- public function getSeenUsers (int $ offset = 0 ): \Iterator {
839- $ limit = 1000 ;
831+ public function getSeenUsers (int $ offset = 0 , ?int $ limit = null ): \Iterator {
832+ $ maxBatchSize = 1000 ;
840833
841834 do {
842- $ userIds = $ this ->getSeenUserIds ($ limit , $ offset );
843- $ offset += $ limit ;
835+ if ($ limit !== null ) {
836+ $ batchSize = min ($ limit , $ maxBatchSize );
837+ $ limit -= $ batchSize ;
838+ } else {
839+ $ batchSize = $ maxBatchSize ;
840+ }
841+
842+ $ userIds = $ this ->getSeenUserIds ($ batchSize , $ offset );
843+ $ offset += $ batchSize ;
844844
845845 foreach ($ userIds as $ userId ) {
846846 foreach ($ this ->backends as $ backend ) {
@@ -851,6 +851,6 @@ public function getSeenUsers(int $offset = 0): \Iterator {
851851 }
852852 }
853853 }
854- } while (count ($ userIds ) === $ limit );
854+ } while (count ($ userIds ) === $ batchSize && $ limit !== 0 );
855855 }
856856}
0 commit comments