summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2019-06-27 10:04:19 +0200
committerGitHub <noreply@github.com>2019-06-27 10:04:19 +0200
commit0d3f9be56e83fe363ec15d0fcc137845a99fc2d6 (patch)
treea7d10c7badeef61272675c476f8edc899b462b0d
parentafb86ef4f5f7a0d032addb33b99be97f206503e6 (diff)
parentd2c8a11c07f27816298cc1e4032f2b66333fa6d2 (diff)
downloadnextcloud-server-0d3f9be56e83fe363ec15d0fcc137845a99fc2d6.tar.gz
nextcloud-server-0d3f9be56e83fe363ec15d0fcc137845a99fc2d6.zip
Merge pull request #16088 from nextcloud/bugfix/noid/allow-longer-comments-to-be-stored-in-the-comments-api
Allow apps to store longer messages in the comments API
-rw-r--r--lib/private/Comments/Comment.php7
-rw-r--r--lib/public/Comments/IComment.php5
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/private/Comments/Comment.php b/lib/private/Comments/Comment.php
index 76c6e1d1f6b..c7cafa0524d 100644
--- a/lib/private/Comments/Comment.php
+++ b/lib/private/Comments/Comment.php
@@ -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;
diff --git a/lib/public/Comments/IComment.php b/lib/public/Comments/IComment.php
index e364d42fe87..c7c846bbe9d 100644
--- a/lib/public/Comments/IComment.php
+++ b/lib/public/Comments/IComment.php
@@ -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