diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-07-27 18:50:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-27 18:50:31 +0200 |
commit | 5fb5d85067bfc06a10cd8dbd2a21052a21ec2d81 (patch) | |
tree | 76177c54cb41cef24f8977b9c39095b8bc4b5da5 | |
parent | 767c42f4596fc077480b3729b344c9a261cabe9c (diff) | |
parent | 424937fd39219a35978430c70f2a84e292ce038a (diff) | |
download | nextcloud-server-5fb5d85067bfc06a10cd8dbd2a21052a21ec2d81.tar.gz nextcloud-server-5fb5d85067bfc06a10cd8dbd2a21052a21ec2d81.zip |
Merge pull request #38667 from nextcloud/fix/systemtagmanager-gettag-updatetag
fix(SystemTagManager): Use truncated tagName in getTag and updateTag
-rw-r--r-- | lib/private/SystemTag/SystemTagManager.php | 12 |
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); |