Browse Source

Do not query when the list is empty

tags/v7.0.0alpha2
Joas Schilling 10 years ago
parent
commit
d418e176ce
1 changed files with 16 additions and 14 deletions
  1. 16
    14
      lib/private/share/share.php

+ 16
- 14
lib/private/share/share.php View File

@@ -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;
}
}
}
}

Loading…
Cancel
Save