diff options
author | Joas Schilling <coding@schilljs.com> | 2019-06-26 10:11:46 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-06-26 10:14:24 +0200 |
commit | d2c8a11c07f27816298cc1e4032f2b66333fa6d2 (patch) | |
tree | 347738fe39ceebc8f43874cb96d76e51f513760b /lib/private/Comments | |
parent | bc276cdd83aeb40e70ccca4573b4318ca7dceb81 (diff) | |
download | nextcloud-server-d2c8a11c07f27816298cc1e4032f2b66333fa6d2.tar.gz nextcloud-server-d2c8a11c07f27816298cc1e4032f2b66333fa6d2.zip |
Allow apps to store longer messages in the comments API
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r-- | lib/private/Comments/Comment.php | 7 |
1 files changed, 4 insertions, 3 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; |