diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-03-23 14:08:40 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-03-30 22:55:03 +0200 |
commit | 2f4294e7819c5cb298407b7e6101fd4f076969f9 (patch) | |
tree | 675f24310b6b9417faf002b342e9d39af21e02ad /lib/private/Share20/Share.php | |
parent | 00c9974d945f7d50d7d10d7de5fc5a16f4d7421e (diff) | |
download | nextcloud-server-2f4294e7819c5cb298407b7e6101fd4f076969f9.tar.gz nextcloud-server-2f4294e7819c5cb298407b7e6101fd4f076969f9.zip |
Add setId and setProviderID to the public interface
Fixes #23337
We only allow the id to be set once!
Diffstat (limited to 'lib/private/Share20/Share.php')
-rw-r--r-- | lib/private/Share20/Share.php | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php index 6edd0e6886a..c361f01216f 100644 --- a/lib/private/Share20/Share.php +++ b/lib/private/Share20/Share.php @@ -26,6 +26,7 @@ use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\IUser; use OCP\IGroup; +use OCP\Share\Exceptions\IllegalIDChangeException; class Share implements \OCP\Share\IShare { @@ -75,7 +76,19 @@ class Share implements \OCP\Share\IShare { * @inheritdoc */ public function setId($id) { - $this->id = $id; + if (is_int($id)) { + $id = (string)$id; + } + + if(!is_string($id)) { + throw new \InvalidArgumentException('String expected.'); + } + + if ($this->id !== null) { + throw new IllegalIDChangeException('Not allowed to assign a new internal id to a share'); + } + + $this->id = trim($id); return $this; } @@ -100,7 +113,15 @@ class Share implements \OCP\Share\IShare { * @inheritdoc */ public function setProviderId($id) { - $this->providerId = $id; + if(!is_string($id)) { + throw new \InvalidArgumentException('String expected.'); + } + + if ($this->providerId !== null) { + throw new IllegalIDChangeException('Not allowed to assign a new provider id to a share'); + } + + $this->providerId = trim($id); return $this; } |