From 47ecfd98a39e596c8f47dd9a6b14ece4e651f685 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Sat, 18 Apr 2015 15:57:13 +0200 Subject: [PATCH 1/2] DB: remove unused parameter - was forgotten during the migration to doctrine * 377e9a8677afc92bca61fb1bb055901db8457896 <- doctrine merge --- lib/private/db.php | 5 ++--- lib/public/db.php | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/private/db.php b/lib/private/db.php index 7e7bd4dd57..673ad894b6 100644 --- a/lib/private/db.php +++ b/lib/private/db.php @@ -298,17 +298,16 @@ class OC_DB { } } - public static function getErrorCode($error) { + public static function getErrorCode() { $connection = \OC::$server->getDatabaseConnection(); return $connection->errorCode(); } /** * returns the error code and message as a string for logging * works with DoctrineException - * @param mixed $error * @return string */ - public static function getErrorMessage($error) { + public static function getErrorMessage() { $connection = \OC::$server->getDatabaseConnection(); return $connection->getError(); } diff --git a/lib/public/db.php b/lib/public/db.php index 02d0f6ddef..c188352d77 100644 --- a/lib/public/db.php +++ b/lib/public/db.php @@ -125,12 +125,11 @@ class DB { /** * returns the error code and message as a string for logging * works with DoctrineException - * @param mixed $error * @return string * @since 6.0.0 */ - public static function getErrorMessage($error) { - return(\OC_DB::getErrorMessage($error)); + public static function getErrorMessage() { + return(\OC_DB::getErrorMessage()); } } From e837927ad573d1c8fbcecc1759859d6a3465c691 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Sat, 18 Apr 2015 17:02:39 +0200 Subject: [PATCH 2/2] fix followup issues with unneeded parameters --- apps/files_sharing/api/local.php | 2 +- lib/private/db.php | 6 +++--- lib/private/share/share.php | 16 ++++++++-------- lib/private/tags.php | 12 ++++++------ lib/private/user/database.php | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/apps/files_sharing/api/local.php b/apps/files_sharing/api/local.php index 1a5edbfd07..00509bcee6 100644 --- a/apps/files_sharing/api/local.php +++ b/apps/files_sharing/api/local.php @@ -571,7 +571,7 @@ class Local { $result = $query->execute($args); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('files_sharing', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR); + \OCP\Util::writeLog('files_sharing', \OC_DB::getErrorMessage(), \OCP\Util::ERROR); return null; } if ($share = $result->fetchRow()) { diff --git a/lib/private/db.php b/lib/private/db.php index 673ad894b6..98df1c7371 100644 --- a/lib/private/db.php +++ b/lib/private/db.php @@ -290,11 +290,11 @@ class OC_DB { public static function raiseExceptionOnError($result, $message = null) { if(self::isError($result)) { if ($message === null) { - $message = self::getErrorMessage($result); + $message = self::getErrorMessage(); } else { - $message .= ', Root cause:' . self::getErrorMessage($result); + $message .= ', Root cause:' . self::getErrorMessage(); } - throw new \OC\DatabaseException($message, self::getErrorCode($result)); + throw new \OC\DatabaseException($message, self::getErrorCode()); } } diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 729dbe79d3..227a3d5a41 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -153,7 +153,7 @@ class Share extends \OC\Share\Constants { $result = $query->execute(array($source, self::SHARE_TYPE_USER)); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR); + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OC_Log::ERROR); } else { while ($row = $result->fetchRow()) { $shares[] = $row['share_with']; @@ -175,7 +175,7 @@ class Share extends \OC\Share\Constants { $result = $query->execute(array($source, self::SHARE_TYPE_GROUP)); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR); + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OC_Log::ERROR); } else { while ($row = $result->fetchRow()) { $usersInGroup = \OC_Group::usersInGroup($row['share_with']); @@ -199,7 +199,7 @@ class Share extends \OC\Share\Constants { $result = $query->execute(array($source, self::SHARE_TYPE_LINK)); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR); + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR); } else { if ($result->fetchRow()) { $publicShare = true; @@ -218,7 +218,7 @@ class Share extends \OC\Share\Constants { $result = $query->execute(array($source, self::SHARE_TYPE_REMOTE)); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR); + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR); } else { if ($result->fetchRow()) { $remoteShare = true; @@ -256,7 +256,7 @@ class Share extends \OC\Share\Constants { $result = $query->execute(); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR); + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OC_Log::ERROR); } else { while ($row = $result->fetchRow()) { foreach ($fileTargets[$row['fileid']] as $uid => $shareData) { @@ -447,7 +447,7 @@ class Share extends \OC\Share\Constants { $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1); $result = $query->execute(array($token)); if (\OC_DB::isError($result)) { - \OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result) . ', token=' . $token, \OC_Log::ERROR); + \OC_Log::write('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, \OC_Log::ERROR); } $row = $result->fetchRow(); if ($row === false) { @@ -1598,7 +1598,7 @@ class Share extends \OC\Share\Constants { $result = $query->execute($queryArgs); if (\OC_DB::isError($result)) { \OC_Log::write('OCP\Share', - \OC_DB::getErrorMessage($result) . ', select=' . $select . ' where=', + \OC_DB::getErrorMessage() . ', select=' . $select . ' where=', \OC_Log::ERROR); } $items = array(); @@ -1662,7 +1662,7 @@ class Share extends \OC\Share\Constants { $parentResult = $query->execute(array($row['parent'])); if (\OC_DB::isError($result)) { \OC_Log::write('OCP\Share', 'Can\'t select parent: ' . - \OC_DB::getErrorMessage($result) . ', select=' . $select . ' where=' . $where, + \OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where, \OC_Log::ERROR); } else { $parentRow = $parentResult->fetchRow(); diff --git a/lib/private/tags.php b/lib/private/tags.php index 975b6dbfe0..84ee5c98df 100644 --- a/lib/private/tags.php +++ b/lib/private/tags.php @@ -233,7 +233,7 @@ class Tags implements \OCP\ITags { $entry = $entries[$objId][] = $row['category']; } if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); return false; } } @@ -283,7 +283,7 @@ class Tags implements \OCP\ITags { $stmt = \OCP\DB::prepare($sql); $result = $stmt->execute(array($tagId)); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); return false; } } catch(\Exception $e) { @@ -510,7 +510,7 @@ class Tags implements \OCP\ITags { . 'WHERE `uid` = ?'); $result = $stmt->execute(array($arguments['uid'])); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); } } catch(\Exception $e) { \OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), @@ -539,7 +539,7 @@ class Tags implements \OCP\ITags { . 'WHERE `uid` = ?'); $result = $stmt->execute(array($arguments['uid'])); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', __METHOD__. ', DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); } } catch(\Exception $e) { \OCP\Util::writeLog('core', __METHOD__ . ', exception: ' @@ -567,7 +567,7 @@ class Tags implements \OCP\ITags { $stmt = \OCP\DB::prepare($query); $result = $stmt->execute($updates); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR); + \OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); return false; } } catch(\Exception $e) { @@ -725,7 +725,7 @@ class Tags implements \OCP\ITags { $result = $stmt->execute(array($id)); if (\OCP\DB::isError($result)) { \OCP\Util::writeLog('core', - __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage($result), + __METHOD__. 'DB error: ' . \OCP\DB::getErrorMessage(), \OCP\Util::ERROR); return false; } diff --git a/lib/private/user/database.php b/lib/private/user/database.php index 457d40e22d..f2fa0cc39c 100644 --- a/lib/private/user/database.php +++ b/lib/private/user/database.php @@ -200,7 +200,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { $result = $query->execute(array($uid)); if (OC_DB::isError($result)) { - OC_Log::write('core', OC_DB::getErrorMessage($result), OC_Log::ERROR); + OC_Log::write('core', OC_DB::getErrorMessage(), OC_Log::ERROR); return false; } @@ -268,7 +268,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { $query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`'); $result = $query->execute(); if (OC_DB::isError($result)) { - OC_Log::write('core', OC_DB::getErrorMessage($result), OC_Log::ERROR); + OC_Log::write('core', OC_DB::getErrorMessage(), OC_Log::ERROR); return false; } return $result->fetchOne();