From 15e02726d76555ea9eb2dd59a88d2310bcd9b08c Mon Sep 17 00:00:00 2001 From: Arthur Schiwon <blizzz@owncloud.com> Date: Tue, 25 Sep 2012 11:47:45 +0200 Subject: [PATCH] Fix files_sharing update script, by making filesystem and users available --- apps/files_sharing/appinfo/update.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php index 5ef7a8bbb9..dc8c8dd73f 100644 --- a/apps/files_sharing/appinfo/update.php +++ b/apps/files_sharing/appinfo/update.php @@ -5,6 +5,10 @@ if (version_compare($installedVersion, '0.3', '<')) { $query = OCP\DB::prepare('SELECT * FROM `*PREFIX*sharing`'); $result = $query->execute(); $groupShares = array(); + //we need to set up user backends, otherwise creating the shares will fail with "because user does not exist" + OC_User::useBackend(new OC_User_Database()); + OC_Group::useBackend(new OC_Group_Database()); + OC_App::loadApps(array('authentication')); while ($row = $result->fetchRow()) { $itemSource = OC_FileCache::getId($row['source'], ''); if ($itemSource != -1) { @@ -39,6 +43,8 @@ if (version_compare($installedVersion, '0.3', '<')) { $shareWith = $row['uid_shared_with']; } OC_User::setUserId($row['uid_owner']); + //we need to setup the filesystem for the user, otherwise OC_FileSystem::getRoot will fail and break + OC_Util::setupFS($row['uid_owner']); try { OCP\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions); } @@ -46,6 +52,7 @@ if (version_compare($installedVersion, '0.3', '<')) { $update_error = true; echo 'Skipping sharing "'.$row['source'].'" to "'.$shareWith.'" (error is "'.$e->getMessage().'")<br/>'; } + OC_Util::tearDownFS(); } } if ($update_error) { -- GitLab