Skip to content

Commit 4d1acfd

Browse files
committed
Only trigger postDelete hooks when the user was deleted...
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent f6ff60f commit 4d1acfd

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/private/User/User.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ public function delete() {
218218
$notification = \OC::$server->getNotificationManager()->createNotification();
219219
$notification->setUser($this->uid);
220220
\OC::$server->getNotificationManager()->markProcessed($notification);
221-
}
222221

223-
if ($this->emitter) {
224-
$this->emitter->emit('\OC\User', 'postDelete', array($this));
222+
if ($this->emitter) {
223+
$this->emitter->emit('\OC\User', 'postDelete', array($this));
224+
}
225225
}
226226
return !($result === false);
227227
}

tests/lib/User/UserTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,17 @@ public function testSetPasswordHooks() {
435435

436436
public function dataDeleteHooks() {
437437
return [
438-
[true],
439-
[false],
438+
[true, 2],
439+
[false, 1],
440440
];
441441
}
442442

443443
/**
444444
* @dataProvider dataDeleteHooks
445445
* @param bool $result
446+
* @param int $expectedHooks
446447
*/
447-
public function testDeleteHooks($result) {
448+
public function testDeleteHooks($result, $expectedHooks) {
448449
$hooksCalled = 0;
449450
$test = $this;
450451

@@ -521,7 +522,7 @@ public function testDeleteHooks($result) {
521522
$this->restoreService('CommentsManager');
522523
$this->restoreService('NotificationManager');
523524

524-
$this->assertEquals(2, $hooksCalled);
525+
$this->assertEquals($expectedHooks, $hooksCalled);
525526
}
526527

527528
public function testGetCloudId() {

0 commit comments

Comments
 (0)