Skip to content

Commit f0c97fd

Browse files
icewind1991backportbot[bot]
authored andcommitted
fix: don't die if we can't encode file metadata on upload
Signed-off-by: Robin Appelman <robin@icewind.nl> Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent bbe1e04 commit f0c97fd

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/private/FilesMetadata/FilesMetadataManager.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ public function saveMetadata(IFilesMetadata $filesMetadata): void {
160160
}
161161

162162
$json = json_encode($filesMetadata->jsonSerialize());
163+
if (!$json) {
164+
$this->logger->error('Failed to json encode file metadata for ' . $filesMetadata->getFileId(), ['metadata' => $filesMetadata->jsonSerialize()]);
165+
return;
166+
}
163167
if (strlen($json) > self::JSON_MAXSIZE) {
164168
$this->logger->debug('huge metadata content detected: ' . $json);
165169
throw new FilesMetadataException('json cannot exceed ' . self::JSON_MAXSIZE . ' characters long; fileId: ' . $filesMetadata->getFileId() . '; size: ' . strlen($json));

0 commit comments

Comments
 (0)