summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/appinfo/update.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/appinfo/update.php')
-rw-r--r--apps/files_sharing/appinfo/update.php27
1 files changed, 13 insertions, 14 deletions
diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php
index 4b716e764f4..446c94ea540 100644
--- a/apps/files_sharing/appinfo/update.php
+++ b/apps/files_sharing/appinfo/update.php
@@ -71,19 +71,18 @@ if (version_compare($installedVersion, '0.3', '<')) {
}
// clean up oc_share table from files which are no longer exists
-if (version_compare($installedVersion, '0.3.5', '<')) {
+if (version_compare($installedVersion, '0.3.5.6', '<')) {
+ // delete all shares where the original file no longer exists
+ $findShares = \OC_DB::prepare('SELECT `*PREFIX*share`.`id` ' .
+ 'FROM `*PREFIX*share` LEFT JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` ' .
+ 'WHERE `*PREFIX*filecache`.`fileid` IS NULL AND `*PREFIX*share`.`item_type` IN (\'file\', \'folder\')');
+ $sharesFound = $findShares->execute(array())->fetchAll();
- // get all shares where the original file no longer exists
- $findShares = \OC_DB::prepare('SELECT `file_source` FROM `*PREFIX*share` LEFT JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` WHERE `*PREFIX*filecache`.`fileid` IS NULL AND `*PREFIX*share`.`item_type` IN (\'file\', \'folder\')');
- $sharesFound = $findShares->execute(array())->fetchAll();
-
- // delete those shares from the oc_share table
- if (is_array($sharesFound) && !empty($sharesFound)) {
- $delArray = array();
- foreach ($sharesFound as $share) {
- $delArray[] = $share['file_source'];
- }
- $removeShares = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `file_source` IN (?)');
- $result = $removeShares->execute(array(implode(',', $delArray)));
- }
+ // delete those shares from the oc_share table
+ if (is_array($sharesFound) && !empty($sharesFound)) {
+ $removeShares = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `id` = ? ');
+ foreach ($sharesFound as $share) {
+ $result = $removeShares->execute(array($share['id']));
+ }
+ }
}