diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-07-08 16:56:13 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-07-08 16:56:13 +0200 |
commit | 0ddbf5c9812d869db7df4473637927edaa0da9b1 (patch) | |
tree | 11953abeeb8b14eac7b50a1219272e3fa56a3743 /apps | |
parent | 830c1f2fbfe560f42912315dc423b30578125905 (diff) | |
download | nextcloud-server-0ddbf5c9812d869db7df4473637927edaa0da9b1.tar.gz nextcloud-server-0ddbf5c9812d869db7df4473637927edaa0da9b1.zip |
[stable9.1] Revert invalid commits from master->stable9.1 merge (#25420)
* Revert "Merge pull request #25240 from owncloud/remove-svg"
This reverts commit 8b8d2b679a12f703141de9da71340f1f02151f3d, reversing
changes made to a35747b6fa8f7704bf7333f16a2b867b76acb187.
* Revert "Merge pull request #25253 from owncloud/users-fixotherquotadropdown"
This reverts commit a35747b6fa8f7704bf7333f16a2b867b76acb187, reversing
changes made to a573b6863cbb4eb21feb7fe5a17a9b8fc60cf059.
* Revert "Merge pull request #25314 from owncloud/files_external-backends-config"
This reverts commit a573b6863cbb4eb21feb7fe5a17a9b8fc60cf059, reversing
changes made to 8147eefaeba3822c9331283e973006ad3aeac1f5.
* Revert "Add all properties while creating a subscription (#25318)"
This reverts commit aaf4c3073af2511ab895e982cadae8dc6a143e55.
* Revert "Merge pull request #25276 from owncloud/delete-own-session-token"
This reverts commit e42ce62ce2855c95861eeae669508e5c20f99be4, reversing
changes made to aaf4c3073af2511ab895e982cadae8dc6a143e55.
* Revert "Merge pull request #25262 from owncloud/fed-sharing-error"
This reverts commit 027715f9acba4dc314a7e4c63ac41a58d4e33f22, reversing
changes made to e42ce62ce2855c95861eeae669508e5c20f99be4.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 25 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/CalDavBackendTest.php | 8 | ||||
-rw-r--r-- | apps/federatedfilesharing/lib/FederatedShareProvider.php | 59 | ||||
-rw-r--r-- | apps/federatedfilesharing/tests/FederatedShareProviderTest.php | 60 | ||||
-rw-r--r-- | apps/files_external/lib/Command/Backends.php | 21 |
5 files changed, 41 insertions, 132 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 565ad0ec663..ce494082976 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1079,27 +1079,22 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription 'lastmodified' => time(), ]; - $propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments']; - foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) { - if (array_key_exists($xmlName, $properties)) { - $values[$dbName] = $properties[$xmlName]; - if (in_array($dbName, $propertiesBoolean)) { - $values[$dbName] = true; - } + if (isset($properties[$xmlName])) { + + $values[$dbName] = $properties[$xmlName]; + $fieldNames[] = $dbName; } } - $valuesToInsert = array(); - $query = $this->db->getQueryBuilder(); - - foreach (array_keys($values) as $name) { - $valuesToInsert[$name] = $query->createNamedParameter($values[$name]); - } - $query->insert('calendarsubscriptions') - ->values($valuesToInsert) + ->values([ + 'principaluri' => $query->createNamedParameter($values['principaluri']), + 'uri' => $query->createNamedParameter($values['uri']), + 'source' => $query->createNamedParameter($values['source']), + 'lastmodified' => $query->createNamedParameter($values['lastmodified']), + ]) ->execute(); return $this->db->lastInsertId('*PREFIX*calendarsubscriptions'); diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index baa8540c43c..977bdf15c8e 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -333,20 +333,15 @@ EOD; public function testSubscriptions() { $id = $this->backend->createSubscription(self::UNIT_TEST_USER, 'Subscription', [ - '{http://calendarserver.org/ns/}source' => new Href('test-source'), - '{http://apple.com/ns/ical/}calendar-color' => '#1C4587', - '{http://calendarserver.org/ns/}subscribed-strip-todos' => '' + '{http://calendarserver.org/ns/}source' => new Href('test-source') ]); $subscriptions = $this->backend->getSubscriptionsForUser(self::UNIT_TEST_USER); $this->assertEquals(1, count($subscriptions)); - $this->assertEquals('#1C4587', $subscriptions[0]['{http://apple.com/ns/ical/}calendar-color']); - $this->assertEquals(true, $subscriptions[0]['{http://calendarserver.org/ns/}subscribed-strip-todos']); $this->assertEquals($id, $subscriptions[0]['id']); $patch = new PropPatch([ '{DAV:}displayname' => 'Unit test', - '{http://apple.com/ns/ical/}calendar-color' => '#ac0606', ]); $this->backend->updateSubscription($id, $patch); $patch->commit(); @@ -355,7 +350,6 @@ EOD; $this->assertEquals(1, count($subscriptions)); $this->assertEquals($id, $subscriptions[0]['id']); $this->assertEquals('Unit test', $subscriptions[0]['{DAV:}displayname']); - $this->assertEquals('#ac0606', $subscriptions[0]['{http://apple.com/ns/ical/}calendar-color']); $this->backend->deleteSubscription($id); $subscriptions = $this->backend->getSubscriptionsForUser(self::UNIT_TEST_USER); diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 181351816b1..01737256769 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -217,32 +217,28 @@ class FederatedShareProvider implements IShareProvider { $share->getPermissions(), $token ); + $sharedByFederatedId = $share->getSharedBy(); + if ($this->userManager->userExists($sharedByFederatedId)) { + $sharedByFederatedId = $sharedByFederatedId . '@' . $this->addressHandler->generateRemoteURL(); + } + $send = $this->notifications->sendRemoteShare( + $token, + $share->getSharedWith(), + $share->getNode()->getName(), + $shareId, + $share->getShareOwner(), + $share->getShareOwner() . '@' . $this->addressHandler->generateRemoteURL(), + $share->getSharedBy(), + $sharedByFederatedId + ); - try { - $sharedByFederatedId = $share->getSharedBy(); - if ($this->userManager->userExists($sharedByFederatedId)) { - $sharedByFederatedId = $sharedByFederatedId . '@' . $this->addressHandler->generateRemoteURL(); - } - $send = $this->notifications->sendRemoteShare( - $token, - $share->getSharedWith(), - $share->getNode()->getName(), - $shareId, - $share->getShareOwner(), - $share->getShareOwner() . '@' . $this->addressHandler->generateRemoteURL(), - $share->getSharedBy(), - $sharedByFederatedId - ); - - if ($send === false) { - $message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable.', - [$share->getNode()->getName(), $share->getSharedWith()]); - throw new \Exception($message_t); - } - } catch (\Exception $e) { - $this->logger->error('Failed to notify remote server of federated share, removing share (' . $e->getMessage() . ')'); - $this->removeShareFromTableById($shareId); - throw $e; + if ($send === false) { + $data = $this->getRawShare($shareId); + $share = $this->createShareObject($data); + $this->removeShareFromTable($share); + $message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable.', + [$share->getNode()->getName(), $share->getSharedWith()]); + throw new \Exception($message_t); } return $shareId; @@ -530,22 +526,13 @@ class FederatedShareProvider implements IShareProvider { * @param IShare $share */ public function removeShareFromTable(IShare $share) { - $this->removeShareFromTableById($share->getId()); - } - - /** - * remove share from table - * - * @param string $shareId - */ - private function removeShareFromTableById($shareId) { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete('share') - ->where($qb->expr()->eq('id', $qb->createNamedParameter($shareId))); + ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))); $qb->execute(); $qb->delete('federated_reshares') - ->where($qb->expr()->eq('share_id', $qb->createNamedParameter($shareId))); + ->where($qb->expr()->eq('share_id', $qb->createNamedParameter($share->getId()))); $qb->execute(); } diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 8c5efdab7b0..6792e534cc6 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -217,6 +217,10 @@ class FederatedShareProviderTest extends \Test\TestCase { 'sharedBy@http://localhost/' )->willReturn(false); + $this->rootFolder->expects($this->once()) + ->method('getUserFolder') + ->with('shareOwner') + ->will($this->returnSelf()); $this->rootFolder->method('getById') ->with('42') ->willReturn([$node]); @@ -240,62 +244,6 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->assertFalse($data); } - public function testCreateException() { - $share = $this->shareManager->newShare(); - - $node = $this->getMock('\OCP\Files\File'); - $node->method('getId')->willReturn(42); - $node->method('getName')->willReturn('myFile'); - - $share->setSharedWith('user@server.com') - ->setSharedBy('sharedBy') - ->setShareOwner('shareOwner') - ->setPermissions(19) - ->setNode($node); - - $this->tokenHandler->method('generateToken')->willReturn('token'); - - $this->addressHandler->expects($this->any())->method('generateRemoteURL') - ->willReturn('http://localhost/'); - $this->addressHandler->expects($this->any())->method('splitUserRemote') - ->willReturn(['user', 'server.com']); - - $this->notifications->expects($this->once()) - ->method('sendRemoteShare') - ->with( - $this->equalTo('token'), - $this->equalTo('user@server.com'), - $this->equalTo('myFile'), - $this->anything(), - 'shareOwner', - 'shareOwner@http://localhost/', - 'sharedBy', - 'sharedBy@http://localhost/' - )->willThrowException(new \Exception('dummy')); - - $this->rootFolder->method('getById') - ->with('42') - ->willReturn([$node]); - - try { - $share = $this->provider->create($share); - $this->fail(); - } catch (\Exception $e) { - $this->assertEquals('dummy', $e->getMessage()); - } - - $qb = $this->connection->getQueryBuilder(); - $stmt = $qb->select('*') - ->from('share') - ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) - ->execute(); - - $data = $stmt->fetch(); - $stmt->closeCursor(); - - $this->assertFalse($data); - } - public function testCreateShareWithSelf() { $share = $this->shareManager->newShare(); diff --git a/apps/files_external/lib/Command/Backends.php b/apps/files_external/lib/Command/Backends.php index d1da6db3f6a..260ea210397 100644 --- a/apps/files_external/lib/Command/Backends.php +++ b/apps/files_external/lib/Command/Backends.php @@ -98,30 +98,15 @@ class Backends extends Base { $result = [ 'name' => $data['name'], 'identifier' => $data['identifier'], - 'configuration' => $this->formatConfiguration($data['configuration']) + 'configuration' => array_map(function (DefinitionParameter $parameter) { + return $parameter->getTypeName(); + }, $data['configuration']) ]; if ($backend instanceof Backend) { $result['storage_class'] = $backend->getStorageClass(); $authBackends = $this->backendService->getAuthMechanismsByScheme(array_keys($backend->getAuthSchemes())); $result['supported_authentication_backends'] = array_keys($authBackends); - $authConfig = array_map(function (AuthMechanism $auth) { - return $this->serializeAuthBackend($auth)['configuration']; - }, $authBackends); - $result['authentication_configuration'] = array_combine(array_keys($authBackends), $authConfig); } return $result; } - - /** - * @param DefinitionParameter[] $parameters - * @return string[] - */ - private function formatConfiguration(array $parameters) { - $configuration = array_filter($parameters, function (DefinitionParameter $parameter) { - return $parameter->getType() !== DefinitionParameter::VALUE_HIDDEN; - }); - return array_map(function (DefinitionParameter $parameter) { - return $parameter->getTypeName(); - }, $configuration); - } } |