aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-04-09 15:01:39 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-04-09 15:02:06 +0200
commitd418e176ce4ce3ee07a5b9e632150470c0387f87 (patch)
tree6c5295b568963ec088993194e3ffb3744f86271a
parent015b9b1dac1e7f90e4e28d2b19697bedf83e56fe (diff)
downloadnextcloud-server-d418e176ce4ce3ee07a5b9e632150470c0387f87.tar.gz
nextcloud-server-d418e176ce4ce3ee07a5b9e632150470c0387f87.zip
Do not query when the list is empty
-rw-r--r--lib/private/share/share.php30
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 3d22f6fd450..59826d03039 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -210,21 +210,23 @@ class Share extends \OC\Share\Constants {
$fileTargetIDs = array_keys($fileTargets);
$fileTargetIDs = array_unique($fileTargetIDs);
- $query = \OC_DB::prepare(
- 'SELECT `fileid`, `path`
- FROM `*PREFIX*filecache`
- WHERE `fileid` IN (' . implode(',', $fileTargetIDs) . ')'
- );
- $result = $query->execute();
+ if (!empty($fileTargetIDs)) {
+ $query = \OC_DB::prepare(
+ 'SELECT `fileid`, `path`
+ FROM `*PREFIX*filecache`
+ WHERE `fileid` IN (' . implode(',', $fileTargetIDs) . ')'
+ );
+ $result = $query->execute();
- if (\OCP\DB::isError($result)) {
- \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
- } else {
- while ($row = $result->fetchRow()) {
- foreach ($fileTargets[$row['fileid']] as $uid => $shareData) {
- $sharedPath = '/Shared' . $shareData['file_target'];
- $sharedPath .= substr($path, strlen($row['path']) -5);
- $sharePaths[$uid] = $sharedPath;
+ if (\OCP\DB::isError($result)) {
+ \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
+ } else {
+ while ($row = $result->fetchRow()) {
+ foreach ($fileTargets[$row['fileid']] as $uid => $shareData) {
+ $sharedPath = '/Shared' . $shareData['file_target'];
+ $sharedPath .= substr($path, strlen($row['path']) -5);
+ $sharePaths[$uid] = $sharedPath;
+ }
}
}
}