-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable minimum characters before autocomplete user searches #30798
Conversation
@PVince81 according to your spec from #30313 (comment)
I don't see a better place to block a search pattern length. As for decorators: it's possible to extend User|Group manager with LimitedUserManager | LimitedGroupManager class, overload the methods in question and make OC::$server to return LimitedUserManager instead of UserManager. But it looks too nerdy to me 👓 |
But adding @DeepDiver1975 @butonic @jvillafanez any other fancy ideas ? |
@PVince81 I have a fancy idea: non-static method inside |
@VicDeo sounds good. You can even invent new utility services in the server container that suit our purposes. |
Maybe it's a good time to think about error handling in the user / group manager... returning an empty result just because you don't want to search with less than 4 chars feels bad because any user could think that there isn't any user, not that you're refusing to search with such little information. The problem is that the user / group manager doesn't specify any exception that could be thrown, so I don't expect any error handling to be in place, not even the default "catch all" exception handling with the "something went wrong" message. For the specific check, it depends on how we want this to progress. If there are no plans to add similar functionality, adding the functions in the same class is fine if we consider it as implementation detail (and make those functions private). On the other hand, if we want to make restrictions based on the user type (maybe we want to allow the admin to do a less restrictive search), or any other, we'll likely need to move the functions to an specialized class. |
Codecov Report
@@ Coverage Diff @@
## master #30798 +/- ##
============================================
+ Coverage 62.3% 62.3% +<.01%
+ Complexity 18396 18241 -155
============================================
Files 1141 1142 +1
Lines 68155 68177 +22
Branches 1232 1232
============================================
+ Hits 42461 42481 +20
- Misses 25333 25335 +2
Partials 361 361
Continue to review full report at Codecov.
|
f3530c9
to
4c4332f
Compare
The other alternative is finding all the current HTTP API endpoints that we have and add the limit there. This includes the sharing autocomplete, custom groups and potentially others (gallery app old share dialog) |
lib/public/Util/UserSearch.php
Outdated
/** | ||
* This class provides functions to search users | ||
* | ||
* @since 10.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make that 10.0.8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, it looks like it's the best compromise 👍
see comment
7990475
to
bd606d0
Compare
b28153d
to
7bb43f1
Compare
Comment addressed. |
@VicDeo please backport |
* @return mixed | ||
*/ | ||
public function getSearchMinLength() { | ||
return $this->config->getSystemValue('user.search_min_length', 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pmaier1 note: now the minimum search length will be 4 by default, we'll add this to the release notes.
If an admin wants less or 0 they must change it manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PVince81 we decided allow zero length for backward compatibility reasons. /But I think this is a subject to remove and shouldn't be advertised/
follow up for missed test failure: #30992 |
@VicDeo can you backport with both PRs ? |
@PVince81 Sure. Do you mean 'both PRs as single PR'? |
Stable10: #30994 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
allow limit user/group search by a certain number of characters
Related Issue
#30313
Motivation and Context
For large user lists searching for the first two characters can be very slow to return.
How Has This Been Tested?
Types of changes
Checklist: