Merge pull request #17274 from nextcloud/backport/17252/stable17

[stable17] Fix user with id 0 to be able to comment
This commit is contained in:
Roeland Jago Douma 2019-09-26 22:26:17 +02:00 committed by GitHub
commit 6245481f7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -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 {
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.');
} }

View file

@ -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');