]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix exceptions with bad gravatar URLs
authorEvan Prodromou <evan@status.net>
Thu, 22 Apr 2010 01:19:16 +0000 (18:19 -0700)
committerEvan Prodromou <evan@status.net>
Thu, 22 Apr 2010 01:19:16 +0000 (18:19 -0700)
plugins/OStatus/classes/Ostatus_profile.php

index e3b3daa2c56e7d4fa8037119936a4991794a8ff5..5d3f37cd07e00f4bdeb1349917639020a7ea0cb3 100644 (file)
@@ -1001,7 +1001,7 @@ class Ostatus_profile extends Memcached_DataObject
             return;
         }
         if (!common_valid_http_url($url)) {
-            throw new ServerException(_m("Invalid avatar URL %s"), $url);
+            throw new ServerException(sprintf(_m("Invalid avatar URL %s"), $url));
         }
 
         if ($this->isGroup()) {
@@ -1303,15 +1303,23 @@ class Ostatus_profile extends Memcached_DataObject
 
         $ok = $oprofile->insert();
 
-        if ($ok) {
-            $avatar = self::getActivityObjectAvatar($object, $hints);
-            if ($avatar) {
+        if (!$ok) {
+            throw new ServerException("Can't save OStatus profile");
+        }
+
+        $avatar = self::getActivityObjectAvatar($object, $hints);
+
+        if ($avatar) {
+            try {
                 $oprofile->updateAvatar($avatar);
+            } catch (Exception $ex) {
+                // Profile is saved, but Avatar is messed up. We're
+                // just going to continue.
+                common_log(LOG_WARNING, "Exception saving OStatus profile avatar: ". $ex->getMessage());
             }
-            return $oprofile;
-        } else {
-            throw new ServerException("Can't save OStatus profile");
         }
+
+        return $oprofile;
     }
 
     /**
@@ -1330,7 +1338,11 @@ class Ostatus_profile extends Memcached_DataObject
         }
         $avatar = self::getActivityObjectAvatar($object, $hints);
         if ($avatar) {
-            $this->updateAvatar($avatar);
+            try {
+                $this->updateAvatar($avatar);
+            } catch (Exception $ex) {
+                common_log(LOG_WARNING, "Exception saving OStatus profile avatar: " . $ex->getMessage());
+            }
         }
     }