@@ -607,7 +607,7 @@ public function callForSeenUsers(\Closure $callback) {
607607 }
608608
609609 /**
610- * Getting all userIds that have a listLogin value requires checking the
610+ * Getting all userIds that have a lastLogin value requires checking the
611611 * value in php because on oracle you cannot use a clob in a where clause,
612612 * preventing us from doing a not null or length(value) > 0 check.
613613 *
@@ -780,19 +780,19 @@ public function getDisplayNameCache(): DisplayNameCache {
780780 return $ this ->displayNameCache ;
781781 }
782782
783- /**
784- * Gets the list of users sorted by lastLogin, from most recent to least recent
785- *
786- * @param int $offset from which offset to fetch
787- * @return \Iterator<IUser> list of user IDs
788- * @since 30.0.0
789- */
790- public function getSeenUsers (int $ offset = 0 ): \Iterator {
791- $ limit = 1000 ;
783+ public function getSeenUsers (int $ offset = 0 , ?int $ limit = null ): \Iterator {
784+ $ maxBatchSize = 1000 ;
792785
793786 do {
794- $ userIds = $ this ->getSeenUserIds ($ limit , $ offset );
795- $ offset += $ limit ;
787+ if ($ limit !== null ) {
788+ $ batchSize = min ($ limit , $ maxBatchSize );
789+ $ limit -= $ batchSize ;
790+ } else {
791+ $ batchSize = $ maxBatchSize ;
792+ }
793+
794+ $ userIds = $ this ->getSeenUserIds ($ batchSize , $ offset );
795+ $ offset += $ batchSize ;
796796
797797 foreach ($ userIds as $ userId ) {
798798 foreach ($ this ->backends as $ backend ) {
@@ -803,6 +803,6 @@ public function getSeenUsers(int $offset = 0): \Iterator {
803803 }
804804 }
805805 }
806- } while (count ($ userIds ) === $ limit );
806+ } while (count ($ userIds ) === $ batchSize && $ limit !== 0 );
807807 }
808808}
0 commit comments