introduce callForSeenUsers and countSeenUsers#26361
Conversation
|
@butonic, thanks for your PR! By analyzing the history of the files in this pull request, we identified @PVince81, @rullzer and @DeepDiver1975 to be potential reviewers. |
438a6f5 to
e388086
Compare
There was a problem hiding this comment.
won't work here because even users who haven't logged in might have broken "files_target" and duplicate shares due to the fact that some sharing API calls would set up their FS...
There was a problem hiding this comment.
please add a unit test for this. It will further confirm that it works with all DBs.
|
Good idea ! |
There was a problem hiding this comment.
interface change, can't backport directly
There was a problem hiding this comment.
would it be easier to simply add a flag $onlySeen = false to callForAllUsers to avoid changing the interface ?
There was a problem hiding this comment.
hm, that still changes the return type of countUsers() to int if $onlySeen is true. I left the new methods in the interface ... should I remove them from IUserManager completely? I dislike munching everything into a single call. We can backport it that way, but in the future I want a clean API.
The callForSeenUsers call eg, does not support searching for users because we only have the userid in the preferences. callForAllUsers iterates over the user backends and the LDAP backend may search displayname or emaul in addition to the userid.
There was a problem hiding this comment.
So what to do with the interface breakage ?
In the backport you'd remove the methods from the interface ? Ok.
But then we also need to add checks everywhere if (is_callable($userManager, 'callForSeenUsers')) then call it, else fallback to the old way.
I'm fine adding these methods in 9.2.
There was a problem hiding this comment.
Actually adding methods in 9.2 would also require a new interface IUserManager2 that extends IUserManager.
Unless we assume that no one ever bothered to implement their own user manager... there is currently no config for easy overriding without hacking server.php ...
@DeepDiver1975 thoughts ?
There was a problem hiding this comment.
Somewhere (maybe in another comment), @DeepDiver1975 answered that it is currently not possible anyway to override the interface, so changing it is ok in 9.2
e388086 to
8f38ca8
Compare
|
I was thinking about this : With the user account table I want the call for uses to iterate only over known users. |
ac6b18b to
d57f314
Compare
|
@DeepDiver1975 What is the status af the user account table? For this PR the tests are passing and it is a clear improvement. @PVince81 @DeepDiver1975 can we merge so I can backport to 9.0.? |
| * @since 9.2.0 | ||
| */ | ||
| public function countSeenUsers() { | ||
| $limit = 10000; |
There was a problem hiding this comment.
hard-coded limit ? should we have this as argument ?
There was a problem hiding this comment.
If you pass that as an argument, you will have different hard-coded values for each use. Making it harder to test. If this should be variable, we should inject it as a configuration value with propel, but i think it shouldn't.
| * @since 9.0.0 | ||
| */ | ||
| public function callForSeenUsers (\Closure $callback) { | ||
| $limit = 1000; |
There was a problem hiding this comment.
hardcoded limit ? pass as argument ?
Also, in the count method you hard-coded to 10000 while here only 1000. Any reason ?
There was a problem hiding this comment.
gut feeling. count only iterates. call executes a callback ... who knows what is done in there and how much memory is leaked
|
@PhilippSchaffrath could you review, pls? |
| * if $onlySeen is true only an int is returned | ||
| */ | ||
| public function countUsers() { | ||
| public function countUsers($onlySeen = false) { |
There was a problem hiding this comment.
The domain is a little inconsistent here, i would like $onlySeen to be called something like $hasLoggedIn.
| public function countUsers() { | ||
| public function countUsers($onlySeen = false) { | ||
| if ($onlySeen) { | ||
| return $this->countSeenUsers(); |
There was a problem hiding this comment.
countHasLoggedInUsers()? looks ugly but clarifies, hm k.
There was a problem hiding this comment.
https://github.com/owncloud/windows_network_drive/pull/51 has already been merged we can change the name after getting this in.
There was a problem hiding this comment.
I don't want to block this, it's just a reminder to keep an easy and consistent domain so it's more easy to understand the code.
| continue; | ||
| public function callForAllUsers(\Closure $callback, $search = '', $onlySeen = false) { | ||
| if ($onlySeen) { | ||
| $this->callForSeenUsers($callback); |
There was a problem hiding this comment.
I would like to see a separation here. callForAllUsers should always call a callback for all users, not sometimes if parameter x is set to y only a subset of all users. Since callForSeenUsers already exists, why does it need to be cascaded in here?
There was a problem hiding this comment.
@PVince81 and @DeepDiver1975 wanted a param to make backporting easier since we don't backport API changes ...
| $user4->delete(); | ||
| } | ||
|
|
||
| public function testCallForSeenUsers() { |
DeepDiver1975
left a comment
There was a problem hiding this comment.
Actually adding methods in 9.2 would also require a new interface IUserManager2 that extends IUserManager.
This is only necessary for interfaces where we allow/expect alternative implementations out there.
I see no reason why an alternative implementation would make sense - furthermore there is no way to register one.
d57f314 to
8513f2a
Compare
|
I addressed most issues and also removed the sql hack for oracle because it was unnecessary to order the results in fhe first place. @DeepDiver1975 @PVince81 @PhilippSchaffrath please review |
|
Looks good to me, also tested with 200 LDAP users where only 4 logged in and saw that only 4 got processed for the avatar move. @butonic please adjust the "since" tag from above and this is good from my POV 👍 |
|
@PVince81 done |
|
👍 |
* introduce callForSeenUsers and countSeenUsers * add tests * oracle should support not null on clob * since 9.2.0 Conflicts: lib/private/Repair/MoveAvatarOutsideHome.php lib/private/User/Manager.php tests/lib/User/ManagerTest.php
* introduce callForSeenUsers and countSeenUsers * add tests * oracle should support not null on clob * since 9.2.0
|
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. |
I was running into the upgrade trying to iterate over 170000 zombie users in my two test ldap servers, when only 6 of them ever logged in. Instead of waiting 5-6 hours or maybe even longer I decided to take the time and find a better solution.
This pr introduces callForSeenUsers() and countSeenUsers() to allow only executing a callback for users that logged in at least once and as a result have a home directory that has been initialized. It also helps prevent out of memory errors.
cc @PVince81 @DeepDiver1975 there are at least two further occurences (SyncService and SyncBirthdayCalendar) of callForAllUsers in the dav app, but they seem to be related to calendar and contacts. We might add other callFor???User methods.
Backport to 9 strongly requested ❗ ❕ !!!111einself