Skip to content

Share: Number of results limited before the search pattern has been applied #8899

Closed

Description

@nosignleft

Expected behavior

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

  1. Select groups_only mode in administration
  2. Create more than 15 users "a.user", "b.user", etc. and linked to a common group "1234"
  3. Login with one of the account, and try to share a file to "r.user" or "y.user" for instance
  4. 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

Activity

  1. karlitschek commented on Jun 5, 2014

    @karlitschek
    Contributor

    @schiesbn

  2. PVince81 commented on Aug 19, 2014

    @PVince81
    Contributor
  3. blizzz commented on Aug 21, 2014

    @blizzz
    Contributor

    👎 wlll takes ages with many (really many) users

  4. karlitschek commented on Dec 5, 2014

    @karlitschek
    Contributor

    @craigpg @blizzz How do we move forward here?

  5. PVince81 commented on Mar 26, 2015

    @PVince81
    Contributor

    @blizzz @craigpg wasn't this fix recently ?

    @nosignleft have you tried with 7.0.5 or 8.0.2 ?

  6. nosignleft commented on Mar 29, 2015

    @nosignleft
    Author

    @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);
                    }
    
  7. blizzz commented on Mar 30, 2015

    @blizzz
    Contributor

    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.

  8. locked as resolved and limited conversation to collaborators on Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions