]> source.dussan.org Git - nextcloud-server.git/commitdiff
Catch potential exceptions when accessing the users avatar - e.g. issues with the...
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 29 Jan 2016 14:39:39 +0000 (15:39 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Fri, 29 Jan 2016 14:39:39 +0000 (15:39 +0100)
apps/dav/lib/carddav/converter.php

index 06d3cb4f18e56bfa2518c8d3b350ed5654e855c4..c8d9b94c2675f503ab3da35721b809750bc6a799 100644 (file)
@@ -39,7 +39,7 @@ class Converter {
                $displayName = empty($displayName ) ? $uid : $displayName;
                $emailAddress = $user->getEMailAddress();
                $cloudId = $user->getCloudId();
-               $image = $user->getAvatarImage(-1);
+               $image = $this->getAvatarImage($user);
 
                $vCard = new VCard();
                $vCard->add(new Text($vCard, 'UID', $uid));
@@ -72,7 +72,7 @@ class Converter {
                $displayName = empty($displayName ) ? $uid : $displayName;
                $emailAddress = $user->getEMailAddress();
                $cloudId = $user->getCloudId();
-               $image = $user->getAvatarImage(-1);
+               $image = $this->getAvatarImage($user);
 
                $updated = false;
                if($this->propertyNeedsUpdate($vCard, 'FN', $displayName)) {
@@ -155,4 +155,17 @@ class Converter {
                return $result;
        }
 
+       /**
+        * @param IUser $user
+        * @return null|IImage
+        */
+       private function getAvatarImage(IUser $user) {
+               try {
+                       $image = $user->getAvatarImage(-1);
+                       return $image;
+               } catch (\Exception $ex) {
+                       return null;
+               }
+       }
+
 }