Skip to content

Commit 1cb1b13

Browse files
authored
Merge pull request #17252 from nextcloud/bugfix/noid/user-0-can-not-comment
Fix user with id 0 to be able to comment
2 parents 6ac6701 + e4b36f4 commit 1cb1b13

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/private/Comments/Comment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ public function getActorId() {
299299
public function setActor($actorType, $actorId) {
300300
if(
301301
!is_string($actorType) || !trim($actorType)
302-
|| !is_string($actorId) || !trim($actorId)
302+
|| !is_string($actorId) || $actorId === ''
303303
) {
304304
throw new \InvalidArgumentException('String expected.');
305305
}
306306
$this->data['actorType'] = trim($actorType);
307-
$this->data['actorId'] = trim($actorId);
307+
$this->data['actorId'] = $actorId;
308308
return $this;
309309
}
310310

@@ -385,7 +385,7 @@ public function getObjectId() {
385385
public function setObject($objectType, $objectId) {
386386
if(
387387
!is_string($objectType) || !trim($objectType)
388-
|| !is_string($objectId) || !trim($objectId)
388+
|| !is_string($objectId) || trim($objectId) === ''
389389
) {
390390
throw new \InvalidArgumentException('String expected.');
391391
}

lib/private/Comments/Manager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ public function getCommentFromData(array $data): IComment {
118118
*/
119119
protected function prepareCommentForDatabaseWrite(IComment $comment) {
120120
if (!$comment->getActorType()
121-
|| !$comment->getActorId()
121+
|| $comment->getActorId() === ''
122122
|| !$comment->getObjectType()
123-
|| !$comment->getObjectId()
123+
|| $comment->getObjectId() === ''
124124
|| !$comment->getVerb()
125125
) {
126126
throw new \UnexpectedValueException('Actor, Object and Verb information must be provided for saving');

0 commit comments

Comments
 (0)