]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't waste energy unless necessary
authorJoas Schilling <coding@schilljs.com>
Thu, 2 Mar 2017 10:24:56 +0000 (11:24 +0100)
committerJoas Schilling <coding@schilljs.com>
Mon, 6 Mar 2017 08:48:57 +0000 (09:48 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/dav/lib/CalDAV/CalDavBackend.php
apps/dav/lib/CardDAV/CardDavBackend.php

index dfef311132495359e512e05cdbdd3771e76de730..e8f1cf979a5bfa53164b8de231d6e99beb1382b7 100644 (file)
@@ -278,6 +278,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
                        ->execute();
 
                while($row = $result->fetch()) {
+                       if (isset($calendars[$row['id']])) {
+                               continue;
+                       }
+
                        list(, $name) = URLUtil::splitPath($row['principaluri']);
                        $uri = $row['uri'] . '_shared_by_' . $name;
                        $row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
@@ -301,9 +305,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
                                $calendar[$xmlName] = $row[$dbName];
                        }
 
-                       if (!isset($calendars[$calendar['id']])) {
-                               $calendars[$calendar['id']] = $calendar;
-                       }
+                       $calendars[$calendar['id']] = $calendar;
                }
                $result->closeCursor();
 
index b71c6380a91ef44601638bcad6cdfc7807e5186f..ac4b58f53854c47a53d73d95aba8bf92021a27da 100644 (file)
@@ -173,22 +173,25 @@ class CardDavBackend implements BackendInterface, SyncSupport {
                        ->execute();
 
                while($row = $result->fetch()) {
+                       if (isset($addressBooks[$row['id']])) {
+                               continue;
+                       }
+
                        list(, $name) = URLUtil::splitPath($row['principaluri']);
                        $uri = $row['uri'] . '_shared_by_' . $name;
                        $displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
-                       if (!isset($addressBooks[$row['id']])) {
-                               $addressBooks[$row['id']] = [
-                                       'id'  => $row['id'],
-                                       'uri' => $uri,
-                                       'principaluri' => $principalUriOriginal,
-                                       '{DAV:}displayname' => $displayName,
-                                       '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
-                                       '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
-                                       '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
-                                       '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
-                                       '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
-                               ];
-                       }
+
+                       $addressBooks[$row['id']] = [
+                               'id'  => $row['id'],
+                               'uri' => $uri,
+                               'principaluri' => $principalUriOriginal,
+                               '{DAV:}displayname' => $displayName,
+                               '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
+                               '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
+                               '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
+                               '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
+                               '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
+                       ];
                }
                $result->closeCursor();