You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Share: Number of results limited before the search pattern has been applied #8899
When trying to share a file or folder in "groups_only" mode, we should be able to find users beyond the first 15 contacts.
Actual behavior
At least since 6.0.2, the result limit is applied before the search pattern.
Steps to reproduce
Select groups_only mode in administration
Create more than 15 users "a.user", "b.user", etc. and linked to a common group "1234"
Login with one of the account, and try to share a file to "r.user" or "y.user" for instance
The user is not found
Fix
It seems that the code in lib/private/group/manager.php apply the limit of results before the search pattern
--- /var/www/html/sites/pp_otdrive_com/www/lib/private/group/manager.php 2014-04-29 14:25:06.093301644 +0200
+++ lib/private/group/manager.php 2014-06-05 12:28:25.107689319 +0200
@@ -175,7 +175,10 @@
return array();
}
// only user backends have the capability to do a complex search for users
- $groupUsers = $group->searchUsers('', $limit, $offset);
+ // $limit == -1: the limit should not be applied now on an unfiltered result!
+ $groupUsers = $group->searchUsers('', -1, $offset);
$search = trim($search);
if(!empty($search)) {
//TODO: for OC 7 earliest: user backend should get a method to check selected users against a pattern
@PVince81 didn't had the time to try the latest versions, because I have to reapply some custom modifications. But from what I see, reading the source code of the 8.0.2, it might be fixed with the search done chunk by chunk to limit the performance impact.
if(!empty($search)) {
// only user backends have the capability to do a complex search for users
$searchOffset = 0;
$searchLimit = $limit * 100;
if($limit === -1) {
$searchLimit = 500;
}
do {
$filteredUsers = $this->userManager->search($search, $searchLimit, $searchOffset);
foreach($filteredUsers as $filteredUser) {
if($group->inGroup($filteredUser)) {
$groupUsers[]= $filteredUser;
}
}
$searchOffset += $searchLimit;
} while(count($groupUsers) < $searchLimit+$offset && count($filteredUsers) >= $searchLimit);
if($limit === -1) {
$groupUsers = array_slice($groupUsers, $offset);
} else {
$groupUsers = array_slice($groupUsers, $offset, $limit);
}
} else {
$groupUsers = $group->searchUsers('', $limit, $offset);
}
Activity
karlitschek commentedon Jun 5, 2014
@schiesbn
PVince81 commentedon Aug 19, 2014
@blizzz
blizzz commentedon Aug 21, 2014
👎 wlll takes ages with many (really many) users
karlitschek commentedon Dec 5, 2014
@craigpg @blizzz How do we move forward here?
PVince81 commentedon Mar 26, 2015
@blizzz @craigpg wasn't this fix recently ?
@nosignleft have you tried with 7.0.5 or 8.0.2 ?
nosignleft commentedon Mar 29, 2015
@PVince81 didn't had the time to try the latest versions, because I have to reapply some custom modifications. But from what I see, reading the source code of the 8.0.2, it might be fixed with the search done chunk by chunk to limit the performance impact.
blizzz commentedon Mar 30, 2015
I am pretty sure this was fixed some time ago, but don't have a PR at hand. Please reopen, if you come across it again.