]> source.dussan.org Git - nextcloud-server.git/commitdiff
parameter checks for setting actor and object to happen only in one place
authorArthur Schiwon <blizzz@owncloud.com>
Thu, 3 Dec 2015 16:16:51 +0000 (17:16 +0100)
committerArthur Schiwon <blizzz@owncloud.com>
Wed, 9 Dec 2015 13:34:23 +0000 (14:34 +0100)
lib/private/comments/comment.php
lib/private/comments/manager.php

index 2e9e4bd3d84b4707c20ef43746e6efc8d1c9c363..8efd7d5613a41e64bfdae5cc9737d2bee4fe9259 100644 (file)
@@ -229,7 +229,10 @@ class Comment implements IComment {
         * @since 9.0.0
         */
        public function setActor($actorType, $actorId) {
-               if(!is_string($actorType) || !is_string($actorId)) {
+               if(
+                      !is_string($actorType) || empty($actorType)
+                   || !is_string($actorId)   || empty($actorId)
+               ) {
                        throw new \InvalidArgumentException('String expected.');
                }
                $this->data['actorType'] = $actorType;
@@ -312,7 +315,10 @@ class Comment implements IComment {
         * @since 9.0.0
         */
        public function setObject($objectType, $objectId) {
-               if(!is_string($objectType) || !is_string($objectId)) {
+               if(
+                      !is_string($objectType) || empty($objectType)
+                   || !is_string($objectId)   || empty($objectId)
+               ) {
                        throw new \InvalidArgumentException('String expected.');
                }
                $this->data['objectType'] = $objectType;
index 12b90a063d1c43878cc818006bfa9056bb3ffb1a..184e37eb12acf009f314ed5a48cd809e3c2d9830 100644 (file)
@@ -354,20 +354,9 @@ class Manager implements ICommentsManager {
         * @param string $objectType the object type the comment is attached to
         * @param string $objectId the object id the comment is attached to
         * @return IComment
-        * @throws \InvalidArgumentException
         * @since 9.0.0
         */
        public function create($actorType, $actorId, $objectType, $objectId) {
-               if(
-                          !is_string($actorType)  || empty($actorType)
-                       || !is_string($actorId)    || empty($actorId)
-                   || !is_string($objectType) || empty($objectType)
-                   || !is_string($objectId)   || empty($objectId)
-               ) {
-                       // unsure whether it's a good place to enforce it here, since the
-                       // comment instance can be manipulated anyway.
-                       throw new \InvalidArgumentException('All arguments must be non-empty strings');
-               }
                $comment = new Comment();
                $comment
                        ->setActor($actorType, $actorId)