diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-09-12 12:47:18 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-09-12 12:47:33 +0200 |
commit | 0fe3354c61827b55708fc79f81d0edd2ca8b4c00 (patch) | |
tree | efa0d5da4a4fdbf26f3a8ef2cb7a033f85e1bb19 | |
parent | e31dfb643a2b70b1ae7dc467b379fb2026709341 (diff) | |
download | nextcloud-server-4.5.0beta3.tar.gz nextcloud-server-4.5.0beta3.zip |
add proper error logging in OC_User database queriesv4.5.0beta3
-rw-r--r-- | lib/user.php | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/lib/user.php b/lib/user.php index 89dab9f9647..7de2a4b7fe6 100644 --- a/lib/user.php +++ b/lib/user.php @@ -416,9 +416,16 @@ class OC_User { * @param string $userid the user to disable */ public static function disableUser($userid) { - $query = "INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, `configkey`, `configvalue`) VALUES(?, ?, ?, ?)"; - $query = OC_DB::prepare($query); - $query->execute(array($userid, 'core', 'enabled', 'false')); + $sql = "INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, `configkey`, `configvalue`) VALUES(?, ?, ?, ?)"; + $stmt = OC_DB::prepare($sql); + if ( ! OC_DB::isError($stmt) ) { + $result = $stmt->execute(array($userid, 'core', 'enabled', 'false')); + if ( OC_DB::isError($result) ) { + OC_Log::write('OC_User', 'could not enable user: '. OC_DB::getErrorMessage($result), OC_Log::ERROR); + } + } else { + OC_Log::write('OC_User', 'could not disable user: '. OC_DB::getErrorMessage($stmt), OC_Log::ERROR); + } } /** @@ -426,9 +433,16 @@ class OC_User { * @param string $userid */ public static function enableUser($userid) { - $query = "DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?"; - $query = OC_DB::prepare($query); - $query->execute(array($userid, 'core', 'enabled', 'false')); + $sql = "DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?"; + $stmt = OC_DB::prepare($sql); + if ( ! OC_DB::isError($stmt) ) { + $result = $stmt->execute(array($userid, 'core', 'enabled', 'false')); + if ( OC_DB::isError($result) ) { + OC_Log::write('OC_User', 'could not enable user: '. OC_DB::getErrorMessage($result), OC_Log::ERROR); + } + } else { + OC_Log::write('OC_User', 'could not enable user: '. OC_DB::getErrorMessage($stmt), OC_Log::ERROR); + } } /** @@ -437,10 +451,19 @@ class OC_User { * @return bool */ public static function isEnabled($userid) { - $query = "SELECT `userid` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?"; - $query = OC_DB::prepare($query); - $results = $query->execute(array($userid, 'core', 'enabled', 'false')); - return $results->numRows() ? false : true; + $sql = "SELECT `userid` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?"; + $stmt = OC_DB::prepare($sql); + if ( ! OC_DB::isError($stmt) ) { + $result = $stmt->execute(array($userid, 'core', 'enabled', 'false')); + if ( ! OC_DB::isError($result) ) { + return $result->numRows() ? false : true; + } else { + OC_Log::write('OC_User', 'could not check if enabled: '. OC_DB::getErrorMessage($result), OC_Log::ERROR); + } + } else { + OC_Log::write('OC_User', 'could not check if enabled: '. OC_DB::getErrorMessage($stmt), OC_Log::ERROR); + } + return false; } /** |