summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJamie McClelland <jm@mayfirst.org>2013-11-23 19:47:45 -0500
committerMorris Jobke <morris.jobke@gmail.com>2014-03-13 13:09:31 +0100
commitd58fda7ff3e8f67e7699123eb4cca8248484c9ea (patch)
tree7e9f10fff274937f08b7f319b70bd1396ccd0161 /apps
parent9fa9c791eb09013e38ebe0d7739ab862eae611ce (diff)
downloadnextcloud-server-d58fda7ff3e8f67e7699123eb4cca8248484c9ea.tar.gz
nextcloud-server-d58fda7ff3e8f67e7699123eb4cca8248484c9ea.zip
fix update to remove shares where file doesn't exist on postgres
Without patch, breaks with: Failed to upgrade "files_sharing". Exception="SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "5,179"" See: https://github.com/owncloud/core/issues/5758 removing unnecessary cruft - no parameter is set, none to pass. https://github.com/owncloud/core/issues/5758 removing subquery, making more readable See: https://github.com/owncloud/core/pull/6016#issuecomment-29510979 parameters to sql calls should be arrays https://github.com/owncloud/core/pull/6016 boosting version to ensure fix gets executed properly escaping the sql select statement removing extraneous closing paren.
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/appinfo/update.php27
-rw-r--r--apps/files_sharing/appinfo/version2
2 files changed, 14 insertions, 15 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']));
+ }
+ }
}
diff --git a/apps/files_sharing/appinfo/version b/apps/files_sharing/appinfo/version
index 09e9157034c..8f91d33378e 100644
--- a/apps/files_sharing/appinfo/version
+++ b/apps/files_sharing/appinfo/version
@@ -1 +1 @@
-0.3.5 \ No newline at end of file
+0.3.5.6