Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Only trigger postDelete hooks when the user was deleted...
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Sep 29, 2016
commit 4d1acfd4ef7087b8dc7795396c75fd239a6245f4
6 changes: 3 additions & 3 deletions lib/private/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ public function delete() {
$notification = \OC::$server->getNotificationManager()->createNotification();
$notification->setUser($this->uid);
\OC::$server->getNotificationManager()->markProcessed($notification);
}

if ($this->emitter) {
$this->emitter->emit('\OC\User', 'postDelete', array($this));
if ($this->emitter) {
$this->emitter->emit('\OC\User', 'postDelete', array($this));
}
}
return !($result === false);
}
Expand Down
9 changes: 5 additions & 4 deletions tests/lib/User/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,17 @@ public function testSetPasswordHooks() {

public function dataDeleteHooks() {
return [
[true],
[false],
[true, 2],
[false, 1],
];
}

/**
* @dataProvider dataDeleteHooks
* @param bool $result
* @param int $expectedHooks
*/
public function testDeleteHooks($result) {
public function testDeleteHooks($result, $expectedHooks) {
$hooksCalled = 0;
$test = $this;

Expand Down Expand Up @@ -521,7 +522,7 @@ public function testDeleteHooks($result) {
$this->restoreService('CommentsManager');
$this->restoreService('NotificationManager');

$this->assertEquals(2, $hooksCalled);
$this->assertEquals($expectedHooks, $hooksCalled);
}

public function testGetCloudId() {
Expand Down