aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Comments/Manager.php21
-rw-r--r--tests/lib/Comments/ManagerTest.php5
2 files changed, 21 insertions, 5 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index 5c7e532f177..534de6a937b 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -102,7 +102,9 @@ class Manager implements ICommentsManager {
}
$data['children_count'] = (int)$data['children_count'];
$data['reference_id'] = $data['reference_id'] ?? null;
- $data['reactions'] = json_decode($data['reactions'], true);
+ if ($this->supportReactions()) {
+ $data['reactions'] = json_decode($data['reactions'], true);
+ }
return $data;
}
@@ -910,6 +912,9 @@ class Manager implements ICommentsManager {
}
private function deleteReaction(IComment $reaction): void {
+ if (!$this->supportReactions()) {
+ return;
+ }
$qb = $this->dbConn->getQueryBuilder();
$qb->delete('reactions')
->where($qb->expr()->eq('parent_id', $qb->createNamedParameter($reaction->getParentId())))
@@ -930,6 +935,9 @@ class Manager implements ICommentsManager {
* @since 24.0.0
*/
public function getReactionComment(int $parentId, string $actorType, string $actorId, string $reaction): IComment {
+ if (!$this->supportReactions()) {
+ throw new NotFoundException('The database does not support reactions');
+ }
$qb = $this->dbConn->getQueryBuilder();
$messageId = $qb
->select('message_id')
@@ -955,6 +963,7 @@ class Manager implements ICommentsManager {
* @since 24.0.0
*/
public function retrieveAllReactionsWithSpecificReaction(int $parentId, string $reaction): ?array {
+ $this->throwIfNotSupportReactions();
$qb = $this->dbConn->getQueryBuilder();
$result = $qb
->select('message_id')
@@ -975,6 +984,10 @@ class Manager implements ICommentsManager {
return $comments;
}
+ public function supportReactions(): bool {
+ return $this->dbConn->supports4ByteText();
+ }
+
/**
* Retrieve all reactions of a message
*
@@ -984,6 +997,9 @@ class Manager implements ICommentsManager {
* @since 24.0.0
*/
public function retrieveAllReactions(int $parentId): array {
+ if (!$this->supportReactions()) {
+ return [];
+ }
$qb = $this->dbConn->getQueryBuilder();
$result = $qb
->select('message_id')
@@ -1124,6 +1140,9 @@ class Manager implements ICommentsManager {
}
private function addReaction(IComment $reaction): void {
+ if (!$this->supportReactions()) {
+ return;
+ }
// Prevent violate constraint
$qb = $this->dbConn->getQueryBuilder();
$qb->select($qb->func()->count('*'))
diff --git a/tests/lib/Comments/ManagerTest.php b/tests/lib/Comments/ManagerTest.php
index e588630a483..2a837a02abf 100644
--- a/tests/lib/Comments/ManagerTest.php
+++ b/tests/lib/Comments/ManagerTest.php
@@ -2,7 +2,6 @@
namespace Test\Comments;
-use Doctrine\DBAL\Platforms\MySQLPlatform;
use OC\Comments\Comment;
use OC\Comments\Manager;
use OCP\AppFramework\Utility\ITimeFactory;
@@ -876,9 +875,7 @@ class ManagerTest extends TestCase {
}
private function skipIfNotSupport4ByteUTF() {
- // 4 byte UTF doesn't work on mysql
- $params = \OC::$server->get(\OC\DB\Connection::class)->getParams();
- if (\OC::$server->getDatabaseConnection()->getDatabasePlatform() instanceof MySQLPlatform && $params['charset'] !== 'utf8mb4') {
+ if (!$this->getManager()->supportReactions()) {
$this->markTestSkipped('MySQL doesn\'t support 4 byte UTF-8');
}
}