]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow apps to overwrite the maximum length when reading from database 16177/head
authorJoas Schilling <coding@schilljs.com>
Mon, 1 Jul 2019 13:48:26 +0000 (15:48 +0200)
committerBackportbot <backportbot-noreply@rullzer.com>
Mon, 1 Jul 2019 14:39:54 +0000 (14:39 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Comments/Manager.php

index 8df4a84a47756ce2ad547f2e3b05ae368a9626f3..309b682767b027b94b1c6b1faec77655172669bf 100644 (file)
@@ -98,6 +98,15 @@ class Manager implements ICommentsManager {
                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.
@@ -253,7 +262,8 @@ class Manager implements ICommentsManager {
                        throw new NotFoundException();
                }
 
-               $comment = new Comment($this->normalizeDatabaseData($data));
+
+               $comment = $this->getCommentFromData($data);
                $this->cache($comment);
                return $comment;
        }
@@ -308,7 +318,7 @@ class Manager implements ICommentsManager {
 
                $resultStatement = $query->execute();
                while ($data = $resultStatement->fetch()) {
-                       $comment = new Comment($this->normalizeDatabaseData($data));
+                       $comment = $this->getCommentFromData($data);
                        $this->cache($comment);
                        $tree['replies'][] = [
                                'comment' => $comment,
@@ -367,7 +377,7 @@ class Manager implements ICommentsManager {
 
                $resultStatement = $query->execute();
                while ($data = $resultStatement->fetch()) {
-                       $comment = new Comment($this->normalizeDatabaseData($data));
+                       $comment = $this->getCommentFromData($data);
                        $this->cache($comment);
                        $comments[] = $comment;
                }
@@ -455,7 +465,7 @@ class Manager implements ICommentsManager {
 
                $resultStatement = $query->execute();
                while ($data = $resultStatement->fetch()) {
-                       $comment = new Comment($this->normalizeDatabaseData($data));
+                       $comment = $this->getCommentFromData($data);
                        $this->cache($comment);
                        $comments[] = $comment;
                }
@@ -485,7 +495,7 @@ class Manager implements ICommentsManager {
                $result->closeCursor();
 
                if ($row) {
-                       $comment = new Comment($this->normalizeDatabaseData($row));
+                       $comment = $this->getCommentFromData($row);
                        $this->cache($comment);
                        return $comment;
                }
@@ -532,7 +542,7 @@ class Manager implements ICommentsManager {
                $comments = [];
                $result = $query->execute();
                while ($data = $result->fetch()) {
-                       $comment = new Comment($this->normalizeDatabaseData($data));
+                       $comment = $this->getCommentFromData($data);
                        $this->cache($comment);
                        $comments[] = $comment;
                }