Avoid useless profile fetches.
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Sun, 4 Nov 2012 22:51:19 +0000 (23:51 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Sat, 10 Nov 2012 16:04:44 +0000 (17:04 +0100)
Profile should only be refetched if a different visibility level is requested.

Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
classes/user.php

index 4626b85..d2ecc1a 100644 (file)
@@ -363,7 +363,7 @@ class User extends PlUser
         if (!$this->_profile_fetched || $forceFetch) {
             $this->_profile_fetched = true;
             $this->_profile = Profile::get($this, $fields, $visibility);
-        } else if ($this->_profile !== null && !$this->_profile->visibility->equals($visibility)) {
+        } else if ($this->_profile !== null && $visibility !== null && !$this->_profile->visibility->equals($visibility)) {
             return Profile::get($this, $fields, $visibility);
         }
         return $this->_profile;