From 3c37cbdfe7eb29db30dc5b9b62b7430f19419412 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 29 Apr 2015 14:12:12 +0200 Subject: [PATCH] Correctly select file cache values also when checking group shares --- lib/private/share/share.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 617eeeb9d9..d1facc961a 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -333,15 +333,15 @@ class Share extends Constants { $shares = array(); $fileDependent = false; + $where = 'WHERE'; + $fileDependentWhere = ''; if ($itemType === 'file' || $itemType === 'folder') { $fileDependent = true; $column = 'file_source'; - $where = 'INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` '; - $where .= 'INNER JOIN `*PREFIX*storages` ON `numeric_id` = `*PREFIX*filecache`.`storage` '; - $where .= ' WHERE'; + $fileDependentWhere = 'INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` '; + $fileDependentWhere .= 'INNER JOIN `*PREFIX*storages` ON `numeric_id` = `*PREFIX*filecache`.`storage` '; } else { $column = 'item_source'; - $where = 'WHERE'; } $select = self::createSelectStatement(self::FORMAT_NONE, $fileDependent); @@ -364,7 +364,7 @@ class Share extends Constants { $arguments[] = $owner; } - $query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` '. $where); + $query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` '. $fileDependentWhere . $where); $result = \OC_DB::executeAudited($query, $arguments); @@ -380,7 +380,7 @@ class Share extends Constants { $groups = \OC_Group::getUserGroups($user); if (!empty($groups)) { - $where = 'WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)'; + $where = $fileDependentWhere . ' WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)'; $arguments = array($itemSource, $itemType, $groups); $types = array(null, null, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY); @@ -394,7 +394,7 @@ class Share extends Constants { // class isn't static anymore... $conn = \OC_DB::getConnection(); $result = $conn->executeQuery( - 'SELECT * FROM `*PREFIX*share` ' . $where, + 'SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where, $arguments, $types );