From: Joas Schilling Date: Thu, 29 Sep 2016 13:05:47 +0000 (+0200) Subject: Only trigger postDelete hooks when the user was deleted... X-Git-Tag: v10.0.2~110^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F1695%2Fhead;p=nextcloud-server.git Only trigger postDelete hooks when the user was deleted... Signed-off-by: Joas Schilling --- diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 7859db23b6b..decd32ac82e 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -216,10 +216,10 @@ class User implements IUser { $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); } diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index 69bab0b659b..d72d7af7c3a 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -430,16 +430,17 @@ class UserTest extends \Test\TestCase { 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; @@ -516,7 +517,7 @@ class UserTest extends \Test\TestCase { $this->restoreService('CommentsManager'); $this->restoreService('NotificationManager'); - $this->assertEquals(2, $hooksCalled); + $this->assertEquals($expectedHooks, $hooksCalled); } public function testGetCloudId() {