[Pkg-owncloud-commits] [owncloud] 42/70: do not write to database when the value is the same

David Prévot taffit at moszumanska.debian.org
Mon Jul 14 17:38:07 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit ee2886331e8972f041d0ceb51561a24bdc0f6185
Author: Arthur Schiwon <blizzz at owncloud.com>
Date:   Tue Jul 8 00:19:58 2014 +0200

    do not write to database when the value is the same
---
 lib/private/preferences.php | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/private/preferences.php b/lib/private/preferences.php
index d1db25b..a849cc2 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) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list