aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/SystemTag
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2023-06-06 13:58:27 +0200
committerMarcel Klehr <mklehr@gmx.net>2023-07-27 13:56:11 +0200
commit424937fd39219a35978430c70f2a84e292ce038a (patch)
tree2ff4947ae88e80a21f251db111a064523ca58234 /lib/private/SystemTag
parent582e655c011eaea0cd33d8827a90904d1250cb9b (diff)
downloadnextcloud-server-424937fd39219a35978430c70f2a84e292ce038a.tar.gz
nextcloud-server-424937fd39219a35978430c70f2a84e292ce038a.zip
fix(SystemTagManager): Use truncated tagName in getTag and updateTag
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib/private/SystemTag')
-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);