]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
handle notices without profiles better in RSS output
authorEvan Prodromou <evan@status.net>
Tue, 13 Jul 2010 14:42:06 +0000 (10:42 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 13 Jul 2010 14:42:06 +0000 (10:42 -0400)
lib/apiaction.php

index 8de13a62da127b7348380befbddec372ddaa23dc..16dd878142cd2c0482df0498af998c74aea9b365 100644 (file)
@@ -461,6 +461,11 @@ class ApiAction extends Action
     function twitterRssEntryArray($notice)
     {
         $profile = $notice->getProfile();
+
+        if (empty($profile)) {
+            throw new ServerException(sprintf(_('No such profile: %d'), $notice->profile_id));
+        }
+
         $entry = array();
 
         // We trim() to avoid extraneous whitespace in the output
@@ -789,13 +794,23 @@ class ApiAction extends Action
 
         if (is_array($notice)) {
             foreach ($notice as $n) {
-                $entry = $this->twitterRssEntryArray($n);
-                $this->showTwitterRssItem($entry);
+                try {
+                    $entry = $this->twitterRssEntryArray($n);
+                    $this->showTwitterRssItem($entry);
+                } catch (Exception $e) {
+                    common_log(LOG_ERR, "Error with notice {$n->id}: " . $e->getMessage());
+                    // continue on exceptions
+                }
             }
         } else {
             while ($notice->fetch()) {
-                $entry = $this->twitterRssEntryArray($notice);
-                $this->showTwitterRssItem($entry);
+                try {
+                    $entry = $this->twitterRssEntryArray($notice);
+                    $this->showTwitterRssItem($entry);
+                } catch (Exception $e) {
+                    common_log(LOG_ERR,  "Error with notice {$n->id}: " . $e->getMessage());
+                    // continue on exceptions
+                }
             }
         }