diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2013-10-29 15:50:33 +0100 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2013-10-29 15:50:33 +0100 |
commit | f021dad204afab2977417265f121d660d3d71252 (patch) | |
tree | 6f5a574e3c3f61754439b7d529bcecf22c052464 /lib | |
parent | b0b76fe064860d2074c91897a29e0f9ac5705db8 (diff) | |
download | nextcloud-server-f021dad204afab2977417265f121d660d3d71252.tar.gz nextcloud-server-f021dad204afab2977417265f121d660d3d71252.zip |
remove user from cache if he was deleted successfully
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/user.php | 25 | ||||
-rw-r--r-- | lib/private/user/manager.php | 14 |
2 files changed, 30 insertions, 9 deletions
diff --git a/lib/private/user.php b/lib/private/user.php index 6b350d4cf1b..710f0fd66db 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -187,18 +187,25 @@ class OC_User { public static function deleteUser($uid) { $user = self::getManager()->get($uid); if ($user) { - $user->delete(); + $result = $user->delete(); - // We have to delete the user from all groups - foreach (OC_Group::getUserGroups($uid) as $i) { - OC_Group::removeFromGroup($uid, $i); + // if delete was successful we clean-up the rest + if ($result) { + + // We have to delete the user from all groups + foreach (OC_Group::getUserGroups($uid) as $i) { + OC_Group::removeFromGroup($uid, $i); + } + // Delete the user's keys in preferences + OC_Preferences::deleteUser($uid); + + // Delete user files in /data/ + OC_Helper::rmdirr(OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid . '/'); + + // Remove it from the Cache + self::getManager()->delete($uid); } - // Delete the user's keys in preferences - OC_Preferences::deleteUser($uid); - // Delete user files in /data/ - OC_Helper::rmdirr(OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid . '/'); - return true; } else { return false; diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php index 13286bc28a4..703c8cd7413 100644 --- a/lib/private/user/manager.php +++ b/lib/private/user/manager.php @@ -119,6 +119,20 @@ class Manager extends PublicEmitter { } /** + * 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 $loginname |