Skip to content

Commit

Permalink
Merge pull request #2494 from nextcloud/bug/2493/add-typecasts-mimety…
Browse files Browse the repository at this point in the history
…pe-id

fix: add typecast for mimetype
  • Loading branch information
artonge committed Jun 4, 2024
2 parents 8d5b8fc + b442ae9 commit 8da933f
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 @@ -95,7 +95,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 @@ -205,10 +205,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 @@ -233,8 +231,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 @@ -533,8 +530,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 8da933f

Please sign in to comment.