summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-11-06 13:52:25 +0100
committerLukas Reschke <lukas@owncloud.com>2014-11-06 13:52:25 +0100
commitf73d65303601574e1bcc68e0aa8ae8ef4853a118 (patch)
treebdeb0ba2133c3c434691f5575511e3ced69cc683
parentbb15028a00da22496fe3e0b5e1fe86a0fa9705b4 (diff)
parent1eefc21329e1256989fc50a5fe7597989324e47f (diff)
downloadnextcloud-server-f73d65303601574e1bcc68e0aa8ae8ef4853a118.tar.gz
nextcloud-server-f73d65303601574e1bcc68e0aa8ae8ef4853a118.zip
Merge pull request #11972 from owncloud/usermanager-remove-delete
Remove confusingly names \OC\User\Manager::delete and fix the automatic ...
-rw-r--r--lib/private/user.php3
-rw-r--r--lib/private/user/manager.php24
-rw-r--r--tests/lib/app.php7
-rw-r--r--tests/lib/user/manager.php13
4 files changed, 18 insertions, 29 deletions
diff --git a/lib/private/user.php b/lib/private/user.php
index 3c23c19b015..2358f4a14e4 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -211,9 +211,6 @@ class OC_User {
// Delete the users entry in the storage table
\OC\Files\Cache\Storage::remove('home::' . $uid);
-
- // Remove it from the Cache
- self::getManager()->delete($uid);
}
return true;
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php
index 5c155c27aba..4d1612a35ce 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/user/manager.php
@@ -46,17 +46,17 @@ class Manager extends PublicEmitter implements IUserManager {
*/
public function __construct($config = null) {
$this->config = $config;
- $cachedUsers = $this->cachedUsers;
+ $cachedUsers = &$this->cachedUsers;
$this->listen('\OC\User', 'postDelete', function ($user) use (&$cachedUsers) {
- $i = array_search($user, $cachedUsers);
- if ($i !== false) {
- unset($cachedUsers[$i]);
- }
+ /** @var \OC\User\User $user */
+ unset($cachedUsers[$user->getUID()]);
});
$this->listen('\OC\User', 'postLogin', function ($user) {
+ /** @var \OC\User\User $user */
$user->updateLastLoginTimestamp();
});
$this->listen('\OC\User', 'postRememberedLogin', function ($user) {
+ /** @var \OC\User\User $user */
$user->updateLastLoginTimestamp();
});
}
@@ -135,20 +135,6 @@ class Manager extends PublicEmitter implements IUserManager {
}
/**
- * remove deleted user from cache
- *
- * @param string $uid
- * @return bool
- */
- public function delete($uid) {
- if (isset($this->cachedUsers[$uid])) {
- unset($this->cachedUsers[$uid]);
- return true;
- }
- return false;
- }
-
- /**
* Check if the password is valid for the user
*
* @param string $loginname
diff --git a/tests/lib/app.php b/tests/lib/app.php
index e538ebec8a0..5bce3b8c3e6 100644
--- a/tests/lib/app.php
+++ b/tests/lib/app.php
@@ -360,10 +360,7 @@ class Test_App extends PHPUnit_Framework_TestCase {
$user1->delete();
$user2->delete();
$user3->delete();
- // clear user cache...
- $userManager->delete(self::TEST_USER1);
- $userManager->delete(self::TEST_USER2);
- $userManager->delete(self::TEST_USER3);
+
$group1->delete();
$group2->delete();
}
@@ -399,8 +396,6 @@ class Test_App extends PHPUnit_Framework_TestCase {
\OC_User::setUserId(null);
$user1->delete();
- // clear user cache...
- $userManager->delete(self::TEST_USER1);
}
/**
diff --git a/tests/lib/user/manager.php b/tests/lib/user/manager.php
index fd0931af7e4..15b28e61bd5 100644
--- a/tests/lib/user/manager.php
+++ b/tests/lib/user/manager.php
@@ -416,6 +416,17 @@ class Manager extends \PHPUnit_Framework_TestCase {
$users = array_shift($result);
//users from backends shall be summed up
- $this->assertEquals(7+16, $users);
+ $this->assertEquals(7 + 16, $users);
+ }
+
+ public function testDeleteUser() {
+ $manager = new \OC\User\Manager();
+ $backend = new \OC_User_Dummy();
+
+ $backend->createUser('foo', 'bar');
+ $manager->registerBackend($backend);
+ $this->assertTrue($manager->userExists('foo'));
+ $manager->get('foo')->delete();
+ $this->assertFalse($manager->userExists('foo'));
}
}