From: Leon Klingele Date: Wed, 6 Mar 2019 12:07:41 +0000 (+0100) Subject: lib/private/User: do not change user properties if value has not changed X-Git-Tag: v16.0.0RC1~3^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f420647add0f5ffc917301335d82d951a1df502e;p=nextcloud-server.git lib/private/User: do not change user properties if value has not changed Signed-off-by: Morris Jobke --- diff --git a/lib/private/User/User.php b/lib/private/User/User.php index a47ef8dc543..48c913db2a9 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -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); } } diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index 16fde814b85..a800e790370 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -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');