lib/private/User: do not change user properties if value has not changed

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Leon Klingele 2019-03-06 13:07:41 +01:00 committed by Morris Jobke
parent 36618b111f
commit f420647add
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
2 changed files with 10 additions and 22 deletions

View 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);
}
}

View 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');