]> source.dussan.org Git - nextcloud-server.git/commitdiff
lib/private/User: do not change user properties if value has not changed 15052/head
authorLeon Klingele <leon@struktur.de>
Wed, 6 Mar 2019 12:07:41 +0000 (13:07 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 11 Apr 2019 08:11:05 +0000 (10:11 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
lib/private/User/User.php
tests/lib/User/UserTest.php

index a47ef8dc5435ff04615a3894aab34a372edcf2e1..48c913db2a93b07f86d81936ed0c6b30182c3fd7 100644 (file)
@@ -158,12 +158,12 @@ class User implements IUser {
         */
        public function setEMailAddress($mailAddress) {
                $oldMailAddress = $this->getEMailAddress();
-               if($mailAddress === '') {
-                       $this->config->deleteUserValue($this->uid, 'settings', 'email');
-               } else {
-                       $this->config->setUserValue($this->uid, 'settings', 'email', $mailAddress);
-               }
                if($oldMailAddress !== $mailAddress) {
+                       if($mailAddress === '') {
+                               $this->config->deleteUserValue($this->uid, 'settings', 'email');
+                       } else {
+                               $this->config->setUserValue($this->uid, 'settings', 'email', $mailAddress);
+                       }
                        $this->triggerChange('eMailAddress', $mailAddress, $oldMailAddress);
                }
        }
@@ -407,8 +407,8 @@ class User implements IUser {
                        $quota = OC_Helper::computerFileSize($quota);
                        $quota = OC_Helper::humanFileSize($quota);
                }
-               $this->config->setUserValue($this->uid, 'files', 'quota', $quota);
                if($quota !== $oldQuota) {
+                       $this->config->setUserValue($this->uid, 'files', 'quota', $quota);
                        $this->triggerChange('quota', $quota, $oldQuota);
                }
        }
index 16fde814b854fd6db5ea114475fd52d26b322406..a800e7903703473dfcd537023fbe5abe0bb6bcbf 100644 (file)
@@ -676,14 +676,8 @@ class UserTest extends TestCase {
                $config->expects($this->any())
                        ->method('getUserValue')
                        ->willReturn('foo@bar.com');
-               $config->expects($this->once())
-                       ->method('setUserValue')
-                       ->with(
-                               'foo',
-                               'settings',
-                               'email',
-                               'foo@bar.com'
-                       );
+               $config->expects($this->never())
+                       ->method('setUserValue');
 
                $user = new User('foo', $backend, $this->dispatcher, $emitter, $config);
                $user->setEMailAddress('foo@bar.com');
@@ -741,14 +735,8 @@ class UserTest extends TestCase {
                $config->expects($this->any())
                        ->method('getUserValue')
                        ->willReturn('23 TB');
-               $config->expects($this->once())
-                       ->method('setUserValue')
-                       ->with(
-                               'foo',
-                               'files',
-                               'quota',
-                               '23 TB'
-                       );
+               $config->expects($this->never())
+                       ->method('setUserValue');
 
                $user = new User('foo', $backend, $this->dispatcher, $emitter, $config);
                $user->setQuota('23 TB');