diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-05 21:36:43 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-05 21:36:43 -0400 |
commit | ab56d9aff280d4e5b436d8f5d843f586bef9c059 (patch) | |
tree | f77c348e643d33e16bbff8076be22f5e6672326a /app/Model/AvatarFile.php | |
parent | 6b78b882d8e7e23353fa401dd3b34c7c262dab62 (diff) |
Fixed PHP warning when removing a user with no Avatar image
Diffstat (limited to 'app/Model/AvatarFile.php')
-rw-r--r-- | app/Model/AvatarFile.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/Model/AvatarFile.php b/app/Model/AvatarFile.php index c49f9fd5..36784e60 100644 --- a/app/Model/AvatarFile.php +++ b/app/Model/AvatarFile.php @@ -60,14 +60,18 @@ class AvatarFile extends Base public function remove($user_id) { try { - $this->objectStorage->remove($this->getFilename($user_id)); - $result = $this->db->table(User::TABLE)->eq('id', $user_id)->update(array('avatar_path' => '')); - $this->userSession->refresh($user_id); - return $result; + $filename = $this->getFilename($user_id); + + if (! empty($filename)) { + $this->objectStorage->remove($filename); + return $this->db->table(User::TABLE)->eq('id', $user_id)->update(array('avatar_path' => '')); + } } catch (Exception $e) { $this->logger->error($e->getMessage()); return false; } + + return true; } /** |