summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-06-19 22:34:04 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-06-19 22:34:36 +0200
commit37f9e037725de58bd9b611fff759f7d12cc6ee5a (patch)
tree7a6b022a86873d219e6ef8d9b0ff2cf3421619a0 /lib
parent11dc3bb0e15753e54ceca74300963202b397092b (diff)
downloadnextcloud-server-37f9e037725de58bd9b611fff759f7d12cc6ee5a.tar.gz
nextcloud-server-37f9e037725de58bd9b611fff759f7d12cc6ee5a.zip
improved check in oc_preferences if a key already exists
Diffstat (limited to 'lib')
-rw-r--r--lib/preferences.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/preferences.php b/lib/preferences.php
index 5a9ed395085..0f4636f6832 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -139,10 +139,12 @@ class OC_PREFERENCES{
*/
public static function setValue( $user, $app, $key, $value ){
// Check if the key does exist
- $exists = self::getValue( $user, $app, $key, null );
+ $query = OC_DB::prepare( 'SELECT configvalue FROM *PREFIX*preferences WHERE userid = ? AND appid = ? AND configkey = ?' );
+ $values=$query->execute(array($user,$app,$key))->fetchAll();
+ error_log(print_r($values,true));
+ $exists=(count($values)>0);
- // null: does not exist. Insert.
- if( is_null( $exists )){
+ if( !$exists ){
$query = OC_DB::prepare( 'INSERT INTO *PREFIX*preferences ( userid, appid, configkey, configvalue ) VALUES( ?, ?, ?, ? )' );
$query->execute( array( $user, $app, $key, $value ));
}