summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-05 21:36:43 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-05 21:36:43 -0400
commitab56d9aff280d4e5b436d8f5d843f586bef9c059 (patch)
treef77c348e643d33e16bbff8076be22f5e6672326a
parent6b78b882d8e7e23353fa401dd3b34c7c262dab62 (diff)
Fixed PHP warning when removing a user with no Avatar image
-rw-r--r--ChangeLog1
-rw-r--r--app/Controller/AvatarFile.php1
-rw-r--r--app/Model/AvatarFile.php12
-rw-r--r--app/Model/User.php2
4 files changed, 11 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 20bb5e40..7e77a7d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,7 @@ Improvements:
Bug fixes:
+* Fixed PHP warning when removing a user with no Avatar image
* Fixed improper Markdown escaping for some tooltips
* Closing all tasks by column, also update closed tasks
* Fixed wrong task link generation within Markdown text
diff --git a/app/Controller/AvatarFile.php b/app/Controller/AvatarFile.php
index a47cca66..5974cde7 100644
--- a/app/Controller/AvatarFile.php
+++ b/app/Controller/AvatarFile.php
@@ -47,6 +47,7 @@ class AvatarFile extends Base
$this->checkCSRFParam();
$user = $this->getUser();
$this->avatarFile->remove($user['id']);
+ $this->userSession->refresh($user['id']);
$this->response->redirect($this->helper->url->to('AvatarFile', 'show', array('user_id' => $user['id'])));
}
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;
}
/**
diff --git a/app/Model/User.php b/app/Model/User.php
index 57993002..6dd78dbb 100644
--- a/app/Model/User.php
+++ b/app/Model/User.php
@@ -22,7 +22,7 @@ class User extends Base
const TABLE = 'users';
/**
- * Id used for everbody (filtering)
+ * Id used for everybody (filtering)
*
* @var integer
*/