]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Handle removed profile more gracefully in noticelist
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 5 Mar 2014 00:27:27 +0000 (01:27 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 5 Mar 2014 00:27:27 +0000 (01:27 +0100)
Just hide it from the visitor, but log a warning (and error, since
the exception itself logs that).

classes/Notice.php
lib/noticelist.php
lib/threadednoticelist.php

index 2cebc475747e4c426cecc3d1bfe37560cb862b39..c25f702989a6efad6fd285150dd0b9ae1e240e24 100644 (file)
@@ -142,20 +142,20 @@ class Notice extends Managed_DataObject
     const FOLLOWER_SCOPE  = 8;
 
     protected $_profile = -1;
-
+    
     public function getProfile()
     {
         if ($this->_profile === -1) {
             $this->_setProfile(Profile::getKV('id', $this->profile_id));
         }
-        if (!$this->_profile instanceof Profile) {
-            throw new NoProfileException($this->profile_id);
-        }
         return $this->_profile;
     }
     
-    function _setProfile(Profile $profile)
+    public function _setProfile(Profile $profile=null)
     {
+        if (!$profile instanceof Profile) {
+            throw new NoProfileException($this->profile_id);
+        }
         $this->_profile = $profile;
     }
 
@@ -2510,10 +2510,15 @@ class Notice extends Managed_DataObject
        {
                $map = self::getProfiles($notices);
                
-               foreach ($notices as $notice) {
-                       if (array_key_exists($notice->profile_id, $map)) {
-                               $notice->_setProfile($map[$notice->profile_id]);    
-                       }
+               foreach ($notices as $entry=>$notice) {
+            try {
+                       if (array_key_exists($notice->profile_id, $map)) {
+                               $notice->_setProfile($map[$notice->profile_id]);
+                       }
+            } catch (NoProfileException $e) {
+                common_log(LOG_WARNING, "Failed to fill profile in Notice with non-existing entry for profile_id: {$e->id}");
+                unset($notices[$entry]);
+            }
                }
                
                return array_values($map);
index df6e8d98c205522b731c00c7d0677cbcc59b1bfa..b00e476d92a1e11f231fea7b40977f7e096e97c8 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
-
-require_once INSTALLDIR.'/lib/favorform.php';
-require_once INSTALLDIR.'/lib/disfavorform.php';
-require_once INSTALLDIR.'/lib/attachmentlist.php';
+if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
 
 /**
  * widget for displaying a list of notices
@@ -136,8 +130,7 @@ class NoticeList extends Widget
             $profiles = Notice::fillProfiles($notices);
        
             $p = Profile::current();
-       
-            if (!empty($p)) {
+            if ($p instanceof Profile) {
 
                 $ids = array();
        
index c3382897c7b368636b8b967b1ec54f9a0d5a4024..6d8570fbee6a5c422eeb186fae31e5ed755cec17 100644 (file)
@@ -27,9 +27,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
 
 /**
  * widget for displaying a list of notices