Skip to content

Commit

Permalink
fix update to remove shares where file doesn't exist on postgres
Browse files Browse the repository at this point in the history
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: owncloud#5758
  • Loading branch information
jmcclelland committed Nov 24, 2013
1 parent aeefe48 commit 8509994
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions apps/files_sharing/appinfo/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,7 @@

// clean up oc_share table from files which are no longer exists
if (version_compare($installedVersion, '0.3.5', '<')) {

// 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 all shares where the original file no longer exists
$removeShares = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `file_source` IN (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\'))');
$result = $removeShares->execute(array(implode(',', $delArray)));
}

0 comments on commit 8509994

Please sign in to comment.