Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions lib/private/Comments/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ protected function normalizeDatabaseData(array $data) {
return $data;
}


/**
* @param array $data
* @return IComment
*/
public function getCommentFromData(array $data): IComment {
return new Comment($this->normalizeDatabaseData($data));
}

/**
* prepares a comment for an insert or update operation after making sure
* all necessary fields have a value assigned.
Expand Down Expand Up @@ -253,7 +262,8 @@ public function get($id) {
throw new NotFoundException();
}

$comment = new Comment($this->normalizeDatabaseData($data));

$comment = $this->getCommentFromData($data);
$this->cache($comment);
return $comment;
}
Expand Down Expand Up @@ -308,7 +318,7 @@ public function getTree($id, $limit = 0, $offset = 0) {

$resultStatement = $query->execute();
while ($data = $resultStatement->fetch()) {
$comment = new Comment($this->normalizeDatabaseData($data));
$comment = $this->getCommentFromData($data);
$this->cache($comment);
$tree['replies'][] = [
'comment' => $comment,
Expand Down Expand Up @@ -367,7 +377,7 @@ public function getForObject(

$resultStatement = $query->execute();
while ($data = $resultStatement->fetch()) {
$comment = new Comment($this->normalizeDatabaseData($data));
$comment = $this->getCommentFromData($data);
$this->cache($comment);
$comments[] = $comment;
}
Expand Down Expand Up @@ -455,7 +465,7 @@ public function getForObjectSince(

$resultStatement = $query->execute();
while ($data = $resultStatement->fetch()) {
$comment = new Comment($this->normalizeDatabaseData($data));
$comment = $this->getCommentFromData($data);
$this->cache($comment);
$comments[] = $comment;
}
Expand Down Expand Up @@ -485,7 +495,7 @@ protected function getLastKnownComment(string $objectType,
$result->closeCursor();

if ($row) {
$comment = new Comment($this->normalizeDatabaseData($row));
$comment = $this->getCommentFromData($row);
$this->cache($comment);
return $comment;
}
Expand Down Expand Up @@ -532,7 +542,7 @@ public function search(string $search, string $objectType, string $objectId, str
$comments = [];
$result = $query->execute();
while ($data = $result->fetch()) {
$comment = new Comment($this->normalizeDatabaseData($data));
$comment = $this->getCommentFromData($data);
$this->cache($comment);
$comments[] = $comment;
}
Expand Down