From 3338a0f236a5dc8722faccdaef5e8ab1ea73e841 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 8 Jul 2014 00:19:17 +0200 Subject: port of #9500 don't trigger update from checkPassword, it is already called by userExists, this is enough. do not write to database when the value is the same add test cases. also split test classes in a file each, looks like only the first class is being executed also appconfig shall not write to database if the value is unchanged --- lib/private/appconfig.php | 4 ++++ lib/private/preferences.php | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php index f20c4a08426..1874d9f2b19 100644 --- a/lib/private/appconfig.php +++ b/lib/private/appconfig.php @@ -183,6 +183,10 @@ class AppConfig implements \OCP\IAppConfig { ); $this->conn->insert('*PREFIX*appconfig', $data); } else { + $oldValue = $this->getValue($app, $key); + if($oldValue === strval($value)) { + return true; + } $data = array( 'configvalue' => $value, ); diff --git a/lib/private/preferences.php b/lib/private/preferences.php index d1db25bbf09..a849cc23e1a 100644 --- a/lib/private/preferences.php +++ b/lib/private/preferences.php @@ -173,11 +173,16 @@ class Preferences { */ public function setValue($user, $app, $key, $value, $preCondition = null) { // Check if the key does exist - $query = 'SELECT COUNT(*) FROM `*PREFIX*preferences`' + $query = 'SELECT `configvalue` FROM `*PREFIX*preferences`' . ' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?'; - $count = $this->conn->fetchColumn($query, array($user, $app, $key)); - $exists = $count > 0; + $oldValue = $this->conn->fetchColumn($query, array($user, $app, $key)); + $exists = $oldValue !== false; + if($oldValue === strval($value)) { + // no changes + return true; + } + $affectedRows = 0; if (!$exists && $preCondition === null) { -- cgit v1.2.3