Uh oh!
There was an error while loading. Please reload this page.
Bugfix/noid/fix too many event triggers - #15020
Conversation
Signed-off-by: Joas Schilling <coding@schilljs.com>
The event is already triggered in OC\User\User::triggerChange Signed-off-by: Joas Schilling <coding@schilljs.com>
blizzz
commented
Apr 9, 2019
don't you fire it (potentially) twice in the triggerChange() anyhow, with both dispatcher and emitter? |
Signed-off-by: Joas Schilling <coding@schilljs.com>
nickvergessen
commented
Apr 9, 2019
that was exactly the case and what I removed now.... |
| $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { | ||
| /** @var $user \OC\User\User */ | ||
| \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); | ||
| $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value])); |
There was a problem hiding this comment.
Because the very same event is dispatched already in the OC\User\User::triggerChange:
server/lib/private/User/User.php
Lines 466 to 470 in 01b4db6
Right before the legacy hook is emitted, which will call this place and trigger the event again.
nickvergessen
commented
Apr 9, 2019
There is actually another problem. The DAV SyncService listens to both, the User change event: server/apps/dav/lib/HookManager.php Line 96 in 3f9cdee As well as the Account manager changeUser: server/apps/dav/lib/AppInfo/Application.php Lines 151 to 155 in 3f9cdee Therefor the vCard of the user is actually updated 3 times when changing the displayname:
The main issue is, that the Account manager only triggers an update when email/display name changes, and not for any of the other values: server/lib/private/Accounts/Hooks.php Lines 68 to 81 in 3f9cdee I think we should unify this too, getting the update count down to 2 at least. |
| */ | ||
| private function shouldUpdateLookupServer() { | ||
| return $this->lookupServerEnabled || !empty($this->lookupServer); | ||
| return $this->lookupServerEnabled && !empty($this->lookupServer); |
There was a problem hiding this comment.
Extracted to #15022 so we can merge this quickly for 16
Add a break point at
server/lib/private/Server.php
Line 1261 in 3f9cdee
And create a user via console
Before: called 6 times
After: called 1 time
The event was already in place before:
https://github.com/nextcloud/server/blame/ec4b1584fe46df81e3eda1ff374f575d153a966f/lib/private/Server.php#L432
So when I added it in:
https://github.com/nextcloud/server/blame/01b4db62fbc4230cff953a2385d305b149744b86/lib/private/User/User.php#L468
It got actually called twices everytime.
And then the avatar manager listened to it's own event making some extra loops 🙈