Fix delete(), it was going in an infinite loop

remotes/origin/stable45
Michael Gapczynski 13 years ago
parent 8de69fcb18
commit bbbfc2c565
  1. 19
      lib/public/share.php

@ -711,17 +711,26 @@ class Share {
* @param bool * @param bool
*/ */
private static function delete($parent, $excludeParent = false) { private static function delete($parent, $excludeParent = false) {
$query = \OC_DB::prepare('SELECT id FROM *PREFIX*share WHERE parent IN (?)');
$ids = array($parent); $ids = array($parent);
while ($item = $query->execute(array(implode("','", $ids)))->fetchRow()) { $parents = array($parent);
$ids[] = $item['id']; while (!empty($parents)) {
$parents = "'".implode("','", $parents)."'";
$query = \OC_DB::prepare('SELECT id FROM *PREFIX*share WHERE parent IN ('.$parents.')');
$result = $query->execute();
// Reset parents array, only go through loop again if items are found
$parents = array();
while ($item = $result->fetchRow()) {
$ids[] = $item['id'];
$parents[] = $item['id'];
}
} }
if ($excludeParent) { if ($excludeParent) {
unset($ids[0]); unset($ids[0]);
} }
if (!empty($ids)) { if (!empty($ids)) {
$query = \OC_DB::prepare('DELETE FROM *PREFIX*share WHERE id IN (?)'); $ids = "'".implode("','", $ids)."'";
$query->execute(array(implode("','", $ids))); $query = \OC_DB::prepare('DELETE FROM *PREFIX*share WHERE id IN ('.$ids.')');
$query->execute();
} }
} }

Loading…
Cancel
Save