]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
NoResultException returns the failed object
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 7 Oct 2013 22:21:24 +0000 (00:21 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 7 Oct 2013 22:21:24 +0000 (00:21 +0200)
classes/Profile.php
lib/noavatarexception.php
lib/noresultexception.php
lib/profilelist.php

index e1bba076e9e31d0d9020b8d757537395e2afd5c1..ffa5a4643951a122671c4f969633827188b258ba 100644 (file)
@@ -549,14 +549,22 @@ class Profile extends Managed_DataObject
     function getSubscribed($offset=0, $limit=null)
     {
         $subs = Subscription::getSubscribedIDs($this->id, $offset, $limit);
-        $profiles = Profile::listFind('id', $subs);
+        try {
+            $profiles = Profile::listFind('id', $subs);
+        } catch (NoResultException $e) {
+            return $e->obj;
+        }
         return $profiles;
     }
 
     function getSubscribers($offset=0, $limit=null)
     {
         $subs = Subscription::getSubscriberIDs($this->id, $offset, $limit);
-        $profiles = Profile::listFind('id', $subs);
+        try {
+            $profiles = Profile::listFind('id', $subs);
+        } catch (NoResultException $e) {
+            return $e->obj;
+        }
         return $profiles;
     }
 
index 1f90aaf71cdf7383b9a5faa96e6e770e3eecfaed..ac411579c5ce9cea3f86f5fbe8b1b3706dfce72c 100644 (file)
@@ -31,8 +31,11 @@ if (!defined('GNUSOCIAL')) { exit(1); }
 
 class NoAvatarException extends NoResultException
 {
-    public function __construct(Profile $target, Avatar $avatar)
+    public $target;
+
+    public function __construct(Profile $target, Avatar $obj)
     {
-        parent::__construct($avatar);
+        $this->target = $target;
+        parent::__construct($obj);
     }
 }
index 6eb83b89d264e58b5ff51b6596c6d6b46b8baf8e..b664dab5e7bd23f8c62ea2c848680a41a06ce54c 100644 (file)
@@ -31,8 +31,11 @@ if (!defined('GNUSOCIAL')) { exit(1); }
 
 class NoResultException extends ServerException
 {
+    public $obj;    // The object with query that gave no results
+
     public function __construct(DB_DataObject $obj)
     {
+        $this->obj = $obj;
         // We could log an entry here with the search parameters
         parent::__construct(sprintf(_('No result found on %s lookup.'), get_class($obj)));
     }
index 085690b9f7f4a33805789d42565e3f1d71ef1299..11ed8945e9b0c60195561b15ffa8bec15351bab4 100644 (file)
@@ -85,15 +85,8 @@ class ProfileList extends Widget
 
     function showProfiles()
     {
-        // Note: we don't use fetchAll() because it's borked with query()
-
-        $profiles = array();
-
-        while ($this->profile->fetch()) {
-            $profiles[] = clone($this->profile);
-        }
-
-        $cnt = count($profiles);
+        $cnt = $this->profile->N;
+        $profiles = $this->profile->fetchAll();
 
         $max = min($cnt, $this->maxProfiles());