diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-14 10:52:31 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-14 10:52:31 -0400 |
commit | bbbfc2c56543c4d04e470f5429ddec94c61d8c3a (patch) | |
tree | bb67de9c4142cd87f02aa5a4c3f4241f759e85b3 /lib/public | |
parent | 8de69fcb18619a16fcccb9377d6c7b92b5ffe33d (diff) | |
download | nextcloud-server-bbbfc2c56543c4d04e470f5429ddec94c61d8c3a.tar.gz nextcloud-server-bbbfc2c56543c4d04e470f5429ddec94c61d8c3a.zip |
Fix delete(), it was going in an infinite loop
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/share.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/public/share.php b/lib/public/share.php index e1d668c2aec..eeee64327ce 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -711,17 +711,26 @@ class Share { * @param bool */ private static function delete($parent, $excludeParent = false) { - $query = \OC_DB::prepare('SELECT id FROM *PREFIX*share WHERE parent IN (?)'); $ids = array($parent); - while ($item = $query->execute(array(implode("','", $ids)))->fetchRow()) { - $ids[] = $item['id']; + $parents = array($parent); + 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) { unset($ids[0]); } if (!empty($ids)) { - $query = \OC_DB::prepare('DELETE FROM *PREFIX*share WHERE id IN (?)'); - $query->execute(array(implode("','", $ids))); + $ids = "'".implode("','", $ids)."'"; + $query = \OC_DB::prepare('DELETE FROM *PREFIX*share WHERE id IN ('.$ids.')'); + $query->execute(); } } |