]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow apps to store longer messages in the comments API 16105/head
authorJoas Schilling <coding@schilljs.com>
Wed, 26 Jun 2019 08:11:46 +0000 (10:11 +0200)
committerBackportbot <backportbot-noreply@rullzer.com>
Thu, 27 Jun 2019 08:05:02 +0000 (08:05 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Comments/Comment.php
lib/public/Comments/IComment.php

index 76c6e1d1f6b3b806b455c4303dca483be3d4df1f..c7cafa0524dc651f9095e4ec09ff03371f94b0a2 100644 (file)
@@ -188,17 +188,18 @@ class Comment implements IComment {
         * sets the message of the comment and returns itself
         *
         * @param string $message
+        * @param int $maxLength
         * @return IComment
         * @throws MessageTooLongException
         * @since 9.0.0
         */
-       public function setMessage($message) {
+       public function setMessage($message, $maxLength = self::MAX_MESSAGE_LENGTH) {
                if(!is_string($message)) {
                        throw new \InvalidArgumentException('String expected.');
                }
                $message = trim($message);
-               if(mb_strlen($message, 'UTF-8') > IComment::MAX_MESSAGE_LENGTH) {
-                       throw new MessageTooLongException('Comment message must not exceed ' . IComment::MAX_MESSAGE_LENGTH . ' characters');
+               if ($maxLength && mb_strlen($message, 'UTF-8') > $maxLength) {
+                       throw new MessageTooLongException('Comment message must not exceed ' . $maxLength. ' characters');
                }
                $this->data['message'] = $message;
                return $this;
index e364d42fe8777a3d937718b88c343732f9aa8d4e..c7c846bbe9d3361f4073f7555ec91595381401b8 100644 (file)
@@ -127,11 +127,12 @@ interface IComment {
         * MessageTooLongException shall be thrown.
         *
         * @param string $message
+        * @param int $maxLength
         * @return IComment
         * @throws MessageTooLongException
-        * @since 9.0.0
+        * @since 9.0.0 - $maxLength added in 16.0.2
         */
-       public function setMessage($message);
+       public function setMessage($message, $maxLength = self::MAX_MESSAGE_LENGTH);
 
        /**
         * returns an array containing mentions that are included in the comment