Skip to content
Snippets Groups Projects
Unverified Commit 1cb1b132 authored by Roeland Jago Douma's avatar Roeland Jago Douma Committed by GitHub
Browse files

Merge pull request #17252 from nextcloud/bugfix/noid/user-0-can-not-comment

Fix user with id 0 to be able to comment
parents 6ac67011 e4b36f4f
No related branches found
No related tags found
No related merge requests found
...@@ -299,12 +299,12 @@ class Comment implements IComment { ...@@ -299,12 +299,12 @@ class Comment implements IComment {
public function setActor($actorType, $actorId) { public function setActor($actorType, $actorId) {
if( if(
!is_string($actorType) || !trim($actorType) !is_string($actorType) || !trim($actorType)
|| !is_string($actorId) || !trim($actorId) || !is_string($actorId) || $actorId === ''
) { ) {
throw new \InvalidArgumentException('String expected.'); throw new \InvalidArgumentException('String expected.');
} }
$this->data['actorType'] = trim($actorType); $this->data['actorType'] = trim($actorType);
$this->data['actorId'] = trim($actorId); $this->data['actorId'] = $actorId;
return $this; return $this;
} }
...@@ -385,7 +385,7 @@ class Comment implements IComment { ...@@ -385,7 +385,7 @@ class Comment implements IComment {
public function setObject($objectType, $objectId) { public function setObject($objectType, $objectId) {
if( if(
!is_string($objectType) || !trim($objectType) !is_string($objectType) || !trim($objectType)
|| !is_string($objectId) || !trim($objectId) || !is_string($objectId) || trim($objectId) === ''
) { ) {
throw new \InvalidArgumentException('String expected.'); throw new \InvalidArgumentException('String expected.');
} }
......
...@@ -118,9 +118,9 @@ class Manager implements ICommentsManager { ...@@ -118,9 +118,9 @@ class Manager implements ICommentsManager {
*/ */
protected function prepareCommentForDatabaseWrite(IComment $comment) { protected function prepareCommentForDatabaseWrite(IComment $comment) {
if (!$comment->getActorType() if (!$comment->getActorType()
|| !$comment->getActorId() || $comment->getActorId() === ''
|| !$comment->getObjectType() || !$comment->getObjectType()
|| !$comment->getObjectId() || $comment->getObjectId() === ''
|| !$comment->getVerb() || !$comment->getVerb()
) { ) {
throw new \UnexpectedValueException('Actor, Object and Verb information must be provided for saving'); throw new \UnexpectedValueException('Actor, Object and Verb information must be provided for saving');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment