summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2023-06-06 13:58:27 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-07-27 17:03:02 +0000
commitd44a12bb8b885752161e31ca57fa67f09964e0c7 (patch)
tree48a876da0ad5f30c33a5fae379aa5adab181768e
parent5fbb3bb7f0ad070bf541a1401d1bc98f8b516722 (diff)
downloadnextcloud-server-d44a12bb8b885752161e31ca57fa67f09964e0c7.tar.gz
nextcloud-server-d44a12bb8b885752161e31ca57fa67f09964e0c7.zip
fix(SystemTagManager): Use truncated tagName in getTag and updateTag
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
-rw-r--r--lib/private/SystemTag/SystemTagManager.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/private/SystemTag/SystemTagManager.php b/lib/private/SystemTag/SystemTagManager.php
index 65046ebf000..1d5bc10fc2c 100644
--- a/lib/private/SystemTag/SystemTagManager.php
+++ b/lib/private/SystemTag/SystemTagManager.php
@@ -177,8 +177,10 @@ class SystemTagManager implements ISystemTagManager {
* {@inheritdoc}
*/
public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag {
+ // Length of name column is 64
+ $truncatedTagName = substr($tagName, 0, 64);
$result = $this->selectTagQuery
- ->setParameter('name', $tagName)
+ ->setParameter('name', $truncatedTagName)
->setParameter('visibility', $userVisible ? 1 : 0)
->setParameter('editable', $userAssignable ? 1 : 0)
->execute();
@@ -187,7 +189,7 @@ class SystemTagManager implements ISystemTagManager {
$result->closeCursor();
if (!$row) {
throw new TagNotFoundException(
- 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') does not exist'
+ 'Tag ("' . $truncatedTagName . '", '. $userVisible . ', ' . $userAssignable . ') does not exist'
);
}
@@ -247,9 +249,11 @@ class SystemTagManager implements ISystemTagManager {
}
$beforeUpdate = array_shift($tags);
+ // Length of name column is 64
+ $truncatedNewName = substr($newName, 0, 64);
$afterUpdate = new SystemTag(
$tagId,
- $newName,
+ $truncatedNewName,
$userVisible,
$userAssignable
);
@@ -260,7 +264,7 @@ class SystemTagManager implements ISystemTagManager {
->set('visibility', $query->createParameter('visibility'))
->set('editable', $query->createParameter('editable'))
->where($query->expr()->eq('id', $query->createParameter('tagid')))
- ->setParameter('name', $newName)
+ ->setParameter('name', $truncatedNewName)
->setParameter('visibility', $userVisible ? 1 : 0)
->setParameter('editable', $userAssignable ? 1 : 0)
->setParameter('tagid', $tagId);