diff options
author | Marcel Klehr <mklehr@gmx.net> | 2023-02-23 17:34:53 +0100 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2023-02-24 12:55:10 +0100 |
commit | 8151b1b8b04315d7b43329c433a9ef52fe016787 (patch) | |
tree | c50dbddba40f7bd37575cb222a96a0fd6bf2c35a /lib/private/SystemTag | |
parent | 00a7478d8df2007697d5caf2e0cb1c298afbb3fd (diff) | |
download | nextcloud-server-8151b1b8b04315d7b43329c433a9ef52fe016787.tar.gz nextcloud-server-8151b1b8b04315d7b43329c433a9ef52fe016787.zip |
fix(SystemTagManager): Truncate overlong tag names
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'lib/private/SystemTag')
-rw-r--r-- | lib/private/SystemTag/SystemTagManager.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/private/SystemTag/SystemTagManager.php b/lib/private/SystemTag/SystemTagManager.php index 4524aeaf7bc..79c5adcf450 100644 --- a/lib/private/SystemTag/SystemTagManager.php +++ b/lib/private/SystemTag/SystemTagManager.php @@ -193,10 +193,12 @@ class SystemTagManager implements ISystemTagManager { * {@inheritdoc} */ public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag { + // Length of name column is 64 + $truncatedTagName = substr($tagName, 0, 64); $query = $this->connection->getQueryBuilder(); $query->insert(self::TAG_TABLE) ->values([ - 'name' => $query->createNamedParameter($tagName), + 'name' => $query->createNamedParameter($truncatedTagName), 'visibility' => $query->createNamedParameter($userVisible ? 1 : 0), 'editable' => $query->createNamedParameter($userAssignable ? 1 : 0), ]); @@ -205,7 +207,7 @@ class SystemTagManager implements ISystemTagManager { $query->execute(); } catch (UniqueConstraintViolationException $e) { throw new TagAlreadyExistsException( - 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists', + 'Tag ("' . $truncatedTagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists', 0, $e ); @@ -215,7 +217,7 @@ class SystemTagManager implements ISystemTagManager { $tag = new SystemTag( (string)$tagId, - $tagName, + $truncatedTagName, $userVisible, $userAssignable ); |