]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix endless recursion
authorThomas Müller <thomas.mueller@tmit.eu>
Wed, 2 Dec 2015 13:25:07 +0000 (14:25 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Wed, 2 Dec 2015 13:44:41 +0000 (14:44 +0100)
apps/dav/lib/carddav/converter.php
lib/private/user/user.php
tests/lib/user/user.php

index 67492378ade3bcdff774ffb11a0448d0fb3fc699..56b73eba4c0eb6d017375a61228c216e460b601b 100644 (file)
@@ -28,9 +28,10 @@ use Sabre\VObject\Property\Text;
 
 class Converter {
 
-       public function __construct() {
-       }
-
+       /**
+        * @param IUser $user
+        * @return VCard
+        */
        public function createCardFromUser(IUser $user) {
 
                $uid = $user->getUID();
@@ -60,6 +61,11 @@ class Converter {
                return $vCard;
        }
 
+       /**
+        * @param VCard $vCard
+        * @param IUser $user
+        * @return bool
+        */
        public function updateCard(VCard $vCard, IUser $user) {
                $uid = $user->getUID();
                $displayName = $user->getDisplayName();
@@ -105,6 +111,12 @@ class Converter {
                return $updated;
        }
 
+       /**
+        * @param VCard $vCard
+        * @param string $name
+        * @param string|IImage $newValue
+        * @return bool
+        */
        private function propertyNeedsUpdate(VCard $vCard, $name, $newValue) {
                if (is_null($newValue)) {
                        return false;
index d60ffe95fc36a94d92ad7e4d2acf9f0354444a8d..d1fa641504cecd94cf46f4e58044edb4df7c5cde 100644 (file)
@@ -71,14 +71,14 @@ class User implements IUser {
         * @param string $uid
         * @param \OC_User_Interface $backend
         * @param \OC\Hooks\Emitter $emitter
-        * @param \OCP\IConfig $config
+        * @param IConfig|null $config
+        * @param IURLGenerator $urlGenerator
         */
-       public function __construct($uid, $backend, $emitter = null, IConfig $config = null, $avatarManager = null, $urlGenerator = null) {
+       public function __construct($uid, $backend, $emitter = null, IConfig $config = null, $urlGenerator = null) {
                $this->uid = $uid;
                $this->backend = $backend;
                $this->emitter = $emitter;
                $this->config = $config;
-               $this->avatarManager = $avatarManager;
                $this->urlGenerator = $urlGenerator;
                if ($this->config) {
                        $enabled = $this->config->getUserValue($uid, 'core', 'enabled', 'true');
@@ -88,9 +88,6 @@ class User implements IUser {
                        $this->enabled = true;
                        $this->lastLogin = \OC::$server->getConfig()->getUserValue($uid, 'login', 'lastLogin', 0);
                }
-               if (is_null($this->avatarManager)) {
-                       $this->avatarManager = \OC::$server->getAvatarManager();
-               }
                if (is_null($this->urlGenerator)) {
                        $this->urlGenerator = \OC::$server->getURLGenerator();
                }
@@ -106,7 +103,7 @@ class User implements IUser {
        }
 
        /**
-        * get the displayname for the user, if no specific displayname is set it will fallback to the user id
+        * get the display name for the user, if no specific display name is set it will fallback to the user id
         *
         * @return string
         */
@@ -326,6 +323,11 @@ class User implements IUser {
         * @since 9.0.0
         */
        public function getAvatarImage($size) {
+               // delay the initialization
+               if (is_null($this->avatarManager)) {
+                       $this->avatarManager = \OC::$server->getAvatarManager();
+               }
+
                $avatar = $this->avatarManager->getAvatar($this->uid);
                $image = $avatar->get(-1);
                if ($image) {
index 134b79383ea177eed7e4673974acd7ad227bc6bc..1f613edc4e69e5a9b695a054e056d23a1f78d467 100644 (file)
@@ -475,7 +475,7 @@ class User extends \Test\TestCase {
                                ->method('getAbsoluteURL')
                                ->withAnyParameters()
                                ->willReturn('http://localhost:8888/owncloud');
-               $user = new \OC\User\User('foo', $backend, null, null, null, $urlGenerator);
+               $user = new \OC\User\User('foo', $backend, null, null, $urlGenerator);
                $this->assertEquals("foo@localhost:8888/owncloud", $user->getCloudId());
        }
 }