summaryrefslogtreecommitdiffstats
path: root/lib/private/Comments
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-03-29 17:29:32 +0200
committerRobin Appelman <robin@icewind.nl>2017-03-30 12:48:27 +0200
commit212d9fd2776c70b7b21fdea4e4e312530a0a3451 (patch)
treeb1acd0f9624cabc766274945828833acb2866feb /lib/private/Comments
parent429f8ae0114350e9b0c0ff9fd57c9ebccaa6e7a8 (diff)
downloadnextcloud-server-212d9fd2776c70b7b21fdea4e4e312530a0a3451.tar.gz
nextcloud-server-212d9fd2776c70b7b21fdea4e4e312530a0a3451.zip
Add test for getting unread comment count by folder
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r--lib/private/Comments/Manager.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index 517d51f7eb2..490b15120ef 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -25,9 +25,7 @@
namespace OC\Comments;
use Doctrine\DBAL\Exception\DriverException;
-use OC\DB\QueryBuilder\Literal;
-use OC\DB\QueryBuilder\QueryBuilder;
-use OC\DB\QueryBuilder\QueryFunction;
+use Doctrine\DBAL\Platforms\MySqlPlatform;
use OCP\Comments\CommentsEvent;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsEventHandler;
@@ -414,13 +412,14 @@ class Manager implements ICommentsManager {
*/
public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user) {
$qb = $this->dbConn->getQueryBuilder();
+ $castAs = ($this->dbConn->getDatabasePlatform() instanceof MySqlPlatform) ? 'unsigned integer' : 'int';
$query = $qb->select('fileid', $qb->createFunction(
'COUNT(' . $qb->getColumnName('c.id') . ')')
)->from('comments', 'c')
->innerJoin('c', 'filecache', 'f', $qb->expr()->andX(
$qb->expr()->eq('c.object_type', $qb->createNamedParameter('files')),
$qb->expr()->eq('f.fileid', $qb->createFunction(
- 'cast(' . $qb->getColumnName('c.object_id') . ' as int)'
+ 'cast(' . $qb->getColumnName('c.object_id') . ' as ' . $castAs . ')'
))
))
->leftJoin('c', 'comments_read_markers', 'm', $qb->expr()->andX(
@@ -436,7 +435,9 @@ class Manager implements ICommentsManager {
->groupBy('f.fileid');
$resultStatement = $query->execute();
- return $resultStatement->fetchAll(\PDO::FETCH_KEY_PAIR);
+ return array_map(function ($count) {
+ return (int)$count;
+ }, $resultStatement->fetchAll(\PDO::FETCH_KEY_PAIR));
}
/**