]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
Event upgraded to microformats2
[quix0rs-gnu-social.git] / classes / Profile.php
index e48092cd8382f06c00defe93fb39429ec97b5848..862e8ff11a4f34acecb8c982f116672b9a4b90d3 100644 (file)
@@ -92,32 +92,32 @@ class Profile extends Managed_DataObject
         return $user->getProfile();
     } 
 
-    protected $_user = -1;  // Uninitialized value distinct from null
+    protected $_user = array();
 
     public function getUser()
     {
-        if ($this->_user === -1) {
-            $this->_user = User::getKV('id', $this->id);
-        }
-        if (!$this->_user instanceof User) {
-            throw new NoSuchUserException(array('id'=>$this->id));
+        if (!isset($this->_user[$this->id])) {
+            $user = User::getKV('id', $this->id);
+            if (!$user instanceof User) {
+                throw new NoSuchUserException(array('id'=>$this->id));
+            }
+            $this->_user[$this->id] = $user;
         }
-
-        return $this->_user;
+        return $this->_user[$this->id];
     }
 
-    protected $_group = -1;
+    protected $_group = array();
 
     public function getGroup()
     {
-        if ($this->_group === -1) {
-            $this->_group = User_group::getKV('profile_id', $this->id);
-        }
-        if (!$this->_group instanceof User_group) {
-            throw new NoSuchGroupException(array('profile_id'=>$this->id));
+        if (!isset($this->_group[$this->id])) {
+            $group = User_group::getKV('profile_id', $this->id);
+            if (!$group instanceof User_group) {
+                throw new NoSuchGroupException(array('profile_id'=>$this->id));
+            }
+            $this->_group[$this->id] = $group;
         }
-
-        return $this->_group;
+        return $this->_group[$this->id];
     }
 
     public function isGroup()
@@ -140,8 +140,6 @@ class Profile extends Managed_DataObject
         return true;
     }
 
-    protected $_avatars = array();
-
     public function getAvatar($width, $height=null)
     {
         return Avatar::byProfile($this, $width, $height);
@@ -1539,7 +1537,7 @@ class Profile extends Managed_DataObject
     function __sleep()
     {
         $vars = parent::__sleep();
-        $skip = array('_user', '_avatars');
+        $skip = array('_user', '_group');
         return array_diff($vars, $skip);
     }