diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-08 15:28:36 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-09 11:05:29 +0100 |
commit | 426a12baaa6f30aee081358f61108218e11c9e07 (patch) | |
tree | f4c043a0bb284d1c81f36a53e6454baabb98888b /lib | |
parent | ee65cd0bd80d3c46d1210e9a4e8b55b0252de450 (diff) | |
download | nextcloud-server-426a12baaa6f30aee081358f61108218e11c9e07.tar.gz nextcloud-server-426a12baaa6f30aee081358f61108218e11c9e07.zip |
Throw exception
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/share20/manager.php | 17 | ||||
-rw-r--r-- | lib/private/share20/share.php | 2 | ||||
-rw-r--r-- | lib/public/share/ishare.php | 3 |
3 files changed, 17 insertions, 5 deletions
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php index c00d7aa4072..ddf1fa57c54 100644 --- a/lib/private/share20/manager.php +++ b/lib/private/share20/manager.php @@ -261,7 +261,14 @@ class Manager implements IManager { } // If expiredate is empty set a default one if there is a default - if ($share->getFullId() === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) { + $fullId = null; + try { + $fullId = $share->getFullId(); + } catch (\UnexpectedValueException $e) { + // This is a new share + } + + if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) { $expirationDate = new \DateTime(); $expirationDate->setTime(0,0,0); $expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D')); @@ -360,8 +367,12 @@ class Manager implements IManager { $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP); $existingShares = $provider->getSharesByPath($share->getNode()); foreach($existingShares as $existingShare) { - if ($existingShare->getFullId() === $share->getFullId()) { - continue; + try { + if ($existingShare->getFullId() === $share->getFullId()) { + continue; + } + } catch (\UnexpectedValueException $e) { + //It is a new share so just continue } if ($existingShare->getSharedWith() === $share->getSharedWith()) { diff --git a/lib/private/share20/share.php b/lib/private/share20/share.php index eb112d37942..400fc1db64b 100644 --- a/lib/private/share20/share.php +++ b/lib/private/share20/share.php @@ -91,7 +91,7 @@ class Share implements \OCP\Share\IShare { */ public function getFullId() { if ($this->providerId === null || $this->id === null) { - return null; + throw new \UnexpectedValueException; } return $this->providerId . ':' . $this->id; } diff --git a/lib/public/share/ishare.php b/lib/public/share/ishare.php index 8f5175b0dbf..fdf40f19e56 100644 --- a/lib/public/share/ishare.php +++ b/lib/public/share/ishare.php @@ -46,8 +46,9 @@ interface IShare { * Get the full share id. This is the <providerid>:<internalid>. * The full id is unique in the system. * - * @return string|null null is returned when the fullId can't be constructed + * @return string * @since 9.0.0 + * @throws \UnexpectedValueException If the fullId could not be constructed */ public function getFullId(); |