]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove unneeded calls to "ShareManager::shareProviderExists()"
authorDaniel Calviño Sánchez <danxuliu@gmail.com>
Fri, 25 Oct 2019 08:15:50 +0000 (10:15 +0200)
committerDaniel Calviño Sánchez <danxuliu@gmail.com>
Fri, 25 Oct 2019 19:39:49 +0000 (21:39 +0200)
"ShareManager::getSharesBy()" already checks if the share provider
exists before returning the shares and, if the provider does not exist,
it returns an empty array. Therefore it is not needed to explicitly
check if the provider exists or not.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
apps/files_sharing/lib/Controller/ShareAPIController.php
apps/files_sharing/tests/Controller/ShareAPIControllerTest.php

index cde4f93a0f0d38401d2c4aad9a8e63acca4f4ce4..04eb8225fbce9ca27b603cf1102b76d57bd92bdd 100644 (file)
@@ -628,9 +628,7 @@ class ShareAPIController extends OCSController {
                        $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_USER, $node, true, -1, 0));
                        $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_GROUP, $node, true, -1, 0));
                        $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_LINK, $node, true, -1, 0));
-                       if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) {
-                               $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_EMAIL, $node, true, -1, 0));
-                       }
+                       $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_EMAIL, $node, true, -1, 0));
                        if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
                                $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_REMOTE, $node, true, -1, 0));
                        }
@@ -729,16 +727,8 @@ class ShareAPIController extends OCSController {
                $userShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
                $groupShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
                $linkShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
-               if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) {
-                       $mailShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_EMAIL, $path, $reshares, -1, 0);
-               } else {
-                       $mailShares = [];
-               }
-               if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_CIRCLE)) {
-                       $circleShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_CIRCLE, $path, $reshares, -1, 0);
-               } else {
-                       $circleShares = [];
-               }
+               $mailShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_EMAIL, $path, $reshares, -1, 0);
+               $circleShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_CIRCLE, $path, $reshares, -1, 0);
                $roomShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_ROOM, $path, $reshares, -1, 0);
 
                $shares = array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares);
index 4fda1aa41566121efc60ce9a5c9d027348281110..fd6aed09a9fd9e2b854eaea39379d32b3cafa602 100644 (file)
@@ -1093,6 +1093,8 @@ class ShareAPIControllerTest extends TestCase {
                                        $file1UserShareOwnerExpected,
                                        $file1GroupShareOwnerExpected,
                                        $file1LinkShareOwnerExpected,
+                                       $file1EmailShareOwnerExpected,
+                                       $file1CircleShareOwnerExpected,
                                        $file1RoomShareOwnerExpected,
                                ]
                        ],
@@ -1113,8 +1115,6 @@ class ShareAPIControllerTest extends TestCase {
                                        ],
                                ],
                                [
-                                       IShare::TYPE_EMAIL => true,
-                                       IShare::TYPE_CIRCLE => true,
                                        IShare::TYPE_REMOTE => true,
                                        IShare::TYPE_REMOTE_GROUP => true,
                                ],
@@ -1261,6 +1261,7 @@ class ShareAPIControllerTest extends TestCase {
                                        $file1UserShareOwnerExpected,
                                        $file1GroupShareOwnerExpected,
                                        $file1LinkShareOwnerExpected,
+                                       $file1EmailShareOwnerExpected,
                                        $file1RoomShareOwnerExpected,
                                ]
                        ],
@@ -1280,7 +1281,6 @@ class ShareAPIControllerTest extends TestCase {
                                        ],
                                ],
                                [
-                                       IShare::TYPE_EMAIL => true,
                                        IShare::TYPE_REMOTE => true,
                                ],
                                [
@@ -1349,15 +1349,6 @@ class ShareAPIControllerTest extends TestCase {
                                }
                        ));
 
-               $shareProviderExistsMap = [
-                       [IShare::TYPE_EMAIL, $extraShareTypes[IShare::TYPE_EMAIL] ?? false],
-                       [IShare::TYPE_CIRCLE, $extraShareTypes[IShare::TYPE_CIRCLE] ?? false],
-               ];
-
-               $this->shareManager
-                       ->method('shareProviderExists')
-                       ->will($this->returnValueMap($shareProviderExistsMap));
-
                $this->shareManager
                        ->method('outgoingServer2ServerSharesAllowed')
                        ->willReturn($extraShareTypes[ISHARE::TYPE_REMOTE] ?? false);