Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
lib/private/User: do not change user properties if value has not changed
Signed-off-by: Morris Jobke <[email protected]>
  • Loading branch information
Leon Klingele authored and MorrisJobke committed Apr 11, 2019
commit f420647add0f5ffc917301335d82d951a1df502e
12 changes: 6 additions & 6 deletions lib/private/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ public function setDisplayName($displayName) {
*/
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);
}
}
Expand Down Expand Up @@ -407,8 +407,8 @@ public function setQuota($quota) {
$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);
}
}
Expand Down
20 changes: 4 additions & 16 deletions tests/lib/User/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -676,14 +676,8 @@ public function testSetEMailAddressNoChange() {
$config->expects($this->any())
->method('getUserValue')
->willReturn('[email protected]');
$config->expects($this->once())
->method('setUserValue')
->with(
'foo',
'settings',
'email',
'[email protected]'
);
$config->expects($this->never())
->method('setUserValue');

$user = new User('foo', $backend, $this->dispatcher, $emitter, $config);
$user->setEMailAddress('[email protected]');
Expand Down Expand Up @@ -741,14 +735,8 @@ public function testSetQuotaAddressNoChange() {
$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');
Expand Down