From 667f3717db922e5a89338c21f840ad2fda190bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 28 Aug 2013 16:00:27 +0200 Subject: [PATCH] add legacy getSessionByFileId to use getSessionsByFileIds --- lib/session.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/session.php b/lib/session.php index f70d96c2..687bf65e 100644 --- a/lib/session.php +++ b/lib/session.php @@ -71,7 +71,18 @@ class Session { return $info; } - public static function getSessionByFileId($fileIds){ + public static function getSessionByFileId($fileId){ + $sessions = self::getSessionsByFileIds(array($fileId)); + if (count($sessions) === 1) { + return $sessions[0]; + } else { + \OCP\Util::writeLog('documents','more than one session found for file id '.$fileId,\OCP\Util::ERROR); + return $sessions[0]; + } + return null; + } + + public static function getSessionsByFileIds($fileIds){ if (!is_array($fileIds)){ $fileIds = array($fileIds); } @@ -79,8 +90,12 @@ class Session { $placeholders = array_fill(0, $fileIdCount, '?'); $stmt = implode(', ', $placeholders); $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*documents_session` WHERE `file_id` IN (' . $stmt .')'); - $result = $query->execute(array($fileIds)); - return $result->fetchRow(); + $result = $query->execute($fileIds); + $sessions = $result->fetchAll(); + if (!is_array($sessions)){ + $sessions = array(); + } + return $sessions; } public static function getInfoByFileid($fileIds){