Skip to content

Commit

Permalink
Merge pull request #2495 from nextcloud/backport/2494/stable29
Browse files Browse the repository at this point in the history
[stable29] fix: add typecast for mimetype
  • Loading branch information
artonge authored Jun 4, 2024
2 parents c4acc4c + c0819a1 commit 69f9e27
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/Album/AlbumMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function getForUser(string $userId): array {
return new AlbumInfo((int)$row['album_id'], $userId, $row['name'], $row['location'], (int)$row['created'], (int)$row['last_added_photo']);
}, $rows);
}

/**
* @param string $albumName
* @param string $userName
Expand Down Expand Up @@ -220,10 +220,8 @@ public function getForAlbumIdAndUserWithFiles(int $albumId, string $userId): arr

$files = [];
foreach ($rows as $row) {
$albumId = (int)$row['album_id'];
if ($row['fileid']) {
$mimeId = $row['mimetype'];
$mimeType = $this->mimeTypeLoader->getMimetypeById($mimeId);
$mimeType = $this->mimeTypeLoader->getMimetypeById((int)$row['mimetype']);
$files[] = new AlbumFile((int)$row['fileid'], $row['file_name'], $mimeType, (int)$row['size'], (int)$row['mtime'], $row['etag'], (int)$row['added'], $row['owner']);
}
}
Expand All @@ -248,8 +246,7 @@ public function getForAlbumIdAndFileId(int $albumId, int $fileId): AlbumFile {
->andWhere($query->expr()->eq('file_id', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)));
$row = $query->executeQuery()->fetchAll()[0];

$mimeId = $row['mimetype'];
$mimeType = $this->mimeTypeLoader->getMimetypeById($mimeId);
$mimeType = $this->mimeTypeLoader->getMimetypeById((int)$row['mimetype']);
return new AlbumFile((int)$row['fileid'], $row['file_name'], $mimeType, (int)$row['size'], (int)$row['mtime'], $row['etag'], (int)$row['added'], $row['owner']);
}

Expand Down Expand Up @@ -548,8 +545,7 @@ public function getSharedAlbumsForCollaboratorWithFiles(string $collaboratorId,
foreach ($rows as $row) {
$albumId = (int)$row['album_id'];
if ($row['fileid']) {
$mimeId = $row['mimetype'];
$mimeType = $this->mimeTypeLoader->getMimetypeById($mimeId);
$mimeType = $this->mimeTypeLoader->getMimetypeById((int)$row['mimetype']);
$filesByAlbum[$albumId][] = new AlbumFile((int)$row['fileid'], $row['file_name'], $mimeType, (int)$row['size'], (int)$row['mtime'], $row['etag'], (int)$row['added'], $row['owner']);
}

Expand Down

0 comments on commit 69f9e27

Please sign in to comment.