Fixes iterating over profiles of users when all profiles are null.
authorPascal Corpet <pascal.corpet@m4x.org>
Wed, 9 Jun 2010 22:47:37 +0000 (00:47 +0200)
committerPascal Corpet <pascal.corpet@m4x.org>
Sun, 13 Jun 2010 20:53:29 +0000 (22:53 +0200)
classes/profile.php
classes/user.php

index 663f2f7..9aeef1d 100644 (file)
@@ -766,7 +766,7 @@ class Profile
     private static function fetchProfileData(array $pids, $respect_order = true, $fields = 0x0000, $visibility = null)
     {
         if (count($pids) == 0) {
-            return array();
+            return null;
         }
 
         if ($respect_order) {
index 9d95fa4..8761ee7 100644 (file)
@@ -733,7 +733,11 @@ class User extends PlUser
         $table = array();
         if ($fetchProfile) {
             $profiles = Profile::iterOverUIDS($uids, true);
-            $profile = $profiles->next();
+            if ($profiles != null) {
+                $profile = $profiles->next();
+            } else {
+                $profile = null;
+            }
         }
 
         /** We iterate through the users, moving in
@@ -743,7 +747,7 @@ class User extends PlUser
          */
         while (($user = $users->next())) {
             if ($fetchProfile) {
-                if ($profile->owner_id == $user->id()) {
+                if ($profile != null && $profile->owner_id == $user->id()) {
                     $user->_profile = $profile;
                     $profile = $profiles->next();
                 }