From 1dc051a9eb0d8ba9173aa5698dc849c9a19360f4 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Tue, 15 Oct 2013 01:00:27 +0200 Subject: [PATCH] We never accept a user without a Profile --- classes/User.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/User.php b/classes/User.php index e9f1d1b2cf..ca3281107e 100644 --- a/classes/User.php +++ b/classes/User.php @@ -120,16 +120,18 @@ class User extends Managed_DataObject ); } - protected $_profile = -1; + protected $_profile = null; /** * @return Profile + * + * @throws UserNoProfileException if user has no profile */ - function getProfile() + public function getProfile() { - if (is_int($this->_profile) && $this->_profile == -1) { // invalid but distinct from null + if (!($this->_profile instanceof Profile)) { $this->_profile = Profile::getKV('id', $this->id); - if (empty($this->_profile)) { + if (!($this->_profile instanceof Profile)) { throw new UserNoProfileException($this); } }