]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Gravatar/GravatarPlugin.php
Tidying up getUser calls to profiles and some events
[quix0rs-gnu-social.git] / plugins / Gravatar / GravatarPlugin.php
index bdb73f3433b06f966e21a6048f68773d4fe26cda..2cb6bd8cac5a6da6426601d91a0f1d2eb44953ec 100644 (file)
@@ -33,13 +33,17 @@ class GravatarPlugin extends Plugin
     function onEndProfileGetAvatar($profile, $size, &$avatar)
     {
         if (empty($avatar)) {
-            $user = $profile->getUser();
-            if (!empty($user) && !empty($user->email)) {
-                // Fake one!
-                $avatar = new Avatar();
-                $avatar->width = $avatar->height = $size;
-                $avatar->url = $this->gravatar_url($user->email, $size);
-                return false;
+            try {
+                $user = $profile->getUser();
+                if (!empty($user->email)) {
+                    // Fake one!
+                    $avatar = new Avatar();
+                    $avatar->width = $avatar->height = $size;
+                    $avatar->url = $this->gravatar_url($user->email, $size);
+                    return false;
+                }
+            } catch (NoSuchUserException $e) {
+                return true;
             }
         }