Fixed PHP warning when removing a user with no Avatar image

This commit is contained in:
Frederic Guillot
2016-05-05 21:36:43 -04:00
parent 6b78b882d8
commit ab56d9aff2
4 changed files with 11 additions and 5 deletions

View File

@@ -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;
}
/**