diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-24 10:56:34 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-11-24 10:56:34 +0100 |
commit | d785883eb2eb362e949607d6501de7d5289a54a0 (patch) | |
tree | cdd0e51d16651087b1ea17ca7963655a96083b04 /lib | |
parent | cb69e6c2011d43b2c19e594e89cbe7c737aaef1b (diff) | |
parent | 018bd3ee240e2fea9fab30e800a645131670aab2 (diff) | |
download | nextcloud-server-d785883eb2eb362e949607d6501de7d5289a54a0.tar.gz nextcloud-server-d785883eb2eb362e949607d6501de7d5289a54a0.zip |
Merge pull request #20682 from owncloud/objectid-to-string
Make sure that object id can be a string
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/notification/inotification.php | 8 | ||||
-rw-r--r-- | lib/private/notification/notification.php | 16 |
2 files changed, 14 insertions, 10 deletions
diff --git a/lib/private/notification/inotification.php b/lib/private/notification/inotification.php index b79b7f6d9d3..0187abab152 100644 --- a/lib/private/notification/inotification.php +++ b/lib/private/notification/inotification.php @@ -76,10 +76,11 @@ interface INotification { /** * @param string $type - * @param int $id + * @param string $id * @return $this - * @throws \InvalidArgumentException if the object type or id are invalid + * @throws \InvalidArgumentException if the object type or id is invalid * @since 8.2.0 + * @changed 9.0.0 Type of $id changed to string */ public function setObject($type, $id); @@ -90,8 +91,9 @@ interface INotification { public function getObjectType(); /** - * @return int + * @return string * @since 8.2.0 + * @changed 9.0.0 Return type changed to string */ public function getObjectId(); diff --git a/lib/private/notification/notification.php b/lib/private/notification/notification.php index a22d5446f45..70964fc0366 100644 --- a/lib/private/notification/notification.php +++ b/lib/private/notification/notification.php @@ -35,7 +35,7 @@ class Notification implements INotification { /** @var string */ protected $objectType; - /** @var int */ + /** @var string */ protected $objectId; /** @var string */ @@ -83,7 +83,7 @@ class Notification implements INotification { $this->dateTime = new \DateTime(); $this->dateTime->setTimestamp(0); $this->objectType = ''; - $this->objectId = 0; + $this->objectId = ''; $this->subject = ''; $this->subjectParameters = []; $this->subjectParsed = ''; @@ -164,10 +164,11 @@ class Notification implements INotification { /** * @param string $type - * @param int $id + * @param string $id * @return $this * @throws \InvalidArgumentException if the object type or id is invalid * @since 8.2.0 + * @changed 9.0.0 Type of $id changed to string */ public function setObject($type, $id) { if (!is_string($type) || $type === '' || isset($type[64])) { @@ -175,10 +176,10 @@ class Notification implements INotification { } $this->objectType = $type; - if (!is_int($id)) { + if (!is_int($id) && (!is_string($id) || $id === '' || isset($id[64]))) { throw new \InvalidArgumentException('The given object id is invalid'); } - $this->objectId = $id; + $this->objectId = (string) $id; return $this; } @@ -191,8 +192,9 @@ class Notification implements INotification { } /** - * @return int + * @return string * @since 8.2.0 + * @changed 9.0.0 Return type changed to string */ public function getObjectId() { return $this->objectId; @@ -443,7 +445,7 @@ class Notification implements INotification { && $this->getObjectType() !== '' && - $this->getObjectId() !== 0 + $this->getObjectId() !== '' ; } } |