Some type fixes.
This commit is contained in:
parent
0545b04ee1
commit
c2f352c115
|
@ -88,32 +88,32 @@ final class DownloadAction implements SingleActionInterface
|
|||
|
||||
foreach ($query->getArrayResult() as $row) {
|
||||
$customFieldsById = [];
|
||||
foreach ($row['custom_fields'] as $rowCustomField) {
|
||||
foreach ($row['custom_fields'] ?? [] as $rowCustomField) {
|
||||
$customFieldsById[$rowCustomField['field_id']] = $rowCustomField['value'];
|
||||
}
|
||||
|
||||
$playlists = [];
|
||||
foreach ($row['playlists'] as $rowPlaylistMedia) {
|
||||
foreach ($row['playlists'] ?? [] as $rowPlaylistMedia) {
|
||||
if (isset($playlistsById[$rowPlaylistMedia['playlist_id']])) {
|
||||
$playlists[] = $playlistsById[$rowPlaylistMedia['playlist_id']];
|
||||
}
|
||||
}
|
||||
|
||||
$bodyRow = [
|
||||
$row['unique_id'],
|
||||
$row['path'],
|
||||
$row['title'],
|
||||
$row['artist'],
|
||||
$row['album'],
|
||||
$row['genre'],
|
||||
$row['lyrics'],
|
||||
$row['isrc'],
|
||||
$row['amplify'],
|
||||
$row['fade_overlap'],
|
||||
$row['fade_in'],
|
||||
$row['fade_out'],
|
||||
$row['cue_in'],
|
||||
$row['cue_out'],
|
||||
$row['unique_id'] ?? '',
|
||||
$row['path'] ?? '',
|
||||
$row['title'] ?? '',
|
||||
$row['artist'] ?? '',
|
||||
$row['album'] ?? '',
|
||||
$row['genre'] ?? '',
|
||||
$row['lyrics'] ?? '',
|
||||
$row['isrc'] ?? '',
|
||||
$row['amplify'] ?? '',
|
||||
$row['fade_overlap'] ?? '',
|
||||
$row['fade_in'] ?? '',
|
||||
$row['fade_out'] ?? '',
|
||||
$row['cue_in'] ?? '',
|
||||
$row['cue_out'] ?? '',
|
||||
implode(', ', $playlists),
|
||||
];
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ use App\Http\RouterInterface;
|
|||
use App\Http\ServerRequest;
|
||||
use App\Media\MimeType;
|
||||
use App\Paginator;
|
||||
use App\Utilities;
|
||||
use App\Utilities\Strings;
|
||||
use App\Utilities\Types;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use League\Flysystem\StorageAttributes;
|
||||
|
@ -249,7 +250,7 @@ final class ListAction implements SingleActionInterface
|
|||
} elseif (isset($unprocessableMedia[$row->path])) {
|
||||
$row->text = sprintf(
|
||||
__('File Not Processed: %s'),
|
||||
Utilities\Strings::truncateText($unprocessableMedia[$row->path])
|
||||
Strings::truncateText($unprocessableMedia[$row->path])
|
||||
);
|
||||
} elseif (MimeType::isPathImage($row->path)) {
|
||||
$row->is_cover_art = true;
|
||||
|
@ -316,6 +317,21 @@ final class ListAction implements SingleActionInterface
|
|||
'sm.art_updated_at'
|
||||
);
|
||||
|
||||
/** @var array<array{
|
||||
* id: int,
|
||||
* unique_id: string,
|
||||
* song_id: string,
|
||||
* path: string,
|
||||
* artist: string | null,
|
||||
* title: string | null,
|
||||
* album: string | null,
|
||||
* genre: string | null,
|
||||
* isrc: string | null,
|
||||
* length: string,
|
||||
* length_text: string,
|
||||
* art_updated_at: int
|
||||
* }> $mediaInDirRaw
|
||||
*/
|
||||
$mediaInDirRaw = $qb->getQuery()->getScalarResult();
|
||||
|
||||
$mediaIds = array_column($mediaInDirRaw, 'id');
|
||||
|
@ -337,6 +353,13 @@ final class ListAction implements SingleActionInterface
|
|||
}
|
||||
|
||||
// Fetch playlists for all shown media.
|
||||
|
||||
/** @var array<array{
|
||||
* media_id: int,
|
||||
* playlist_id: int,
|
||||
* name: string
|
||||
* }> $allPlaylistsRaw
|
||||
*/
|
||||
$allPlaylistsRaw = $this->em->createQuery(
|
||||
<<<'DQL'
|
||||
SELECT spm.media_id, spm.playlist_id, sp.name
|
||||
|
@ -359,17 +382,17 @@ final class ListAction implements SingleActionInterface
|
|||
$id = $row['id'];
|
||||
$media = new FileListMedia();
|
||||
|
||||
$media->id = (string)$row['song_id'];
|
||||
$media->title = (string)$row['title'];
|
||||
$media->artist = (string)$row['artist'];
|
||||
$media->text = $row['artist'] . ' - ' . $row['title'];
|
||||
$media->album = (string)$row['album'];
|
||||
$media->genre = (string)$row['genre'];
|
||||
$media->isrc = (string)$row['isrc'];
|
||||
$media->id = $row['song_id'];
|
||||
$media->title = $row['title'];
|
||||
$media->artist = $row['artist'];
|
||||
$media->text = ($media->artist ?? '') . ' - ' . ($media->title ?? '');
|
||||
$media->album = $row['album'];
|
||||
$media->genre = $row['genre'];
|
||||
$media->isrc = $row['isrc'];
|
||||
|
||||
$media->is_playable = ($row['length'] !== 0);
|
||||
$media->length = (int)$row['length'];
|
||||
$media->length = Types::int($row['length']);
|
||||
$media->length_text = $row['length_text'];
|
||||
$media->is_playable = ($media->length !== 0);
|
||||
|
||||
$media->media_id = $id;
|
||||
$media->unique_id = $row['unique_id'];
|
||||
|
|
|
@ -8,6 +8,7 @@ use App\Controller\SingleActionInterface;
|
|||
use App\Flysystem\StationFilesystems;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Utilities\Types;
|
||||
use League\Flysystem\StorageAttributes;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
|
@ -25,7 +26,7 @@ final class ListDirectoriesAction implements SingleActionInterface
|
|||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
|
||||
$currentDir = $request->getParam('currentDirectory', '');
|
||||
$currentDir = Types::string($request->getParam('currentDirectory', ''));
|
||||
|
||||
$fsMedia = $this->stationFilesystems->getMediaFilesystem($station);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ use App\Flysystem\StationFilesystems;
|
|||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Media\BatchUtilities;
|
||||
use App\Utilities\Types;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class RenameAction implements SingleActionInterface
|
||||
|
@ -26,13 +27,13 @@ final class RenameAction implements SingleActionInterface
|
|||
Response $response,
|
||||
array $params
|
||||
): ResponseInterface {
|
||||
$from = $request->getParam('file');
|
||||
$from = Types::string($request->getParam('file'));
|
||||
if (empty($from)) {
|
||||
return $response->withStatus(500)
|
||||
->withJson(new Error(500, __('File not specified.')));
|
||||
}
|
||||
|
||||
$to = $request->getParam('newPath');
|
||||
$to = Types::string($request->getParam('newPath'));
|
||||
if (empty($to)) {
|
||||
return $response->withStatus(500)
|
||||
->withJson(new Error(500, __('New path not specified.')));
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Controller\Traits;
|
|||
|
||||
use App\Container\SettingsAwareTrait;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Utilities\Types;
|
||||
use InvalidArgumentException;
|
||||
use lbuchs\WebAuthn\Binary\ByteBuffer;
|
||||
use lbuchs\WebAuthn\WebAuthn;
|
||||
|
@ -50,9 +51,12 @@ trait UsesWebAuthnTrait
|
|||
ServerRequest $request
|
||||
): ByteBuffer {
|
||||
$session = $request->getSession();
|
||||
$challengeRaw = $session->get(self::SESSION_CHALLENGE_KEY);
|
||||
$challengeRaw = Types::stringOrNull(
|
||||
$session->get(self::SESSION_CHALLENGE_KEY),
|
||||
true
|
||||
);
|
||||
|
||||
if (empty($challengeRaw)) {
|
||||
if (null === $challengeRaw) {
|
||||
throw new InvalidArgumentException('Invalid challenge provided.');
|
||||
}
|
||||
|
||||
|
|
|
@ -30,37 +30,37 @@ class Song implements ResolvableUrlInterface
|
|||
description: 'The song artist.',
|
||||
example: 'Chet Porter'
|
||||
)]
|
||||
public string $artist = '';
|
||||
public ?string $artist = '';
|
||||
|
||||
#[OA\Property(
|
||||
description: 'The song title.',
|
||||
example: 'Aluko River'
|
||||
)]
|
||||
public string $title = '';
|
||||
public ?string $title = '';
|
||||
|
||||
#[OA\Property(
|
||||
description: 'The song album.',
|
||||
example: 'Moving Castle'
|
||||
)]
|
||||
public string $album = '';
|
||||
public ?string $album = '';
|
||||
|
||||
#[OA\Property(
|
||||
description: 'The song genre.',
|
||||
example: 'Rock'
|
||||
)]
|
||||
public string $genre = '';
|
||||
public ?string $genre = '';
|
||||
|
||||
#[OA\Property(
|
||||
description: 'The International Standard Recording Code (ISRC) of the file.',
|
||||
example: 'US28E1600021'
|
||||
)]
|
||||
public string $isrc = '';
|
||||
public ?string $isrc = '';
|
||||
|
||||
#[OA\Property(
|
||||
description: 'Lyrics to the song.',
|
||||
example: ''
|
||||
)]
|
||||
public string $lyrics = '';
|
||||
public ?string $lyrics = '';
|
||||
|
||||
#[OA\Property(
|
||||
description: 'URL to the album artwork (if available).',
|
||||
|
|
|
@ -49,6 +49,8 @@ final class DeviceDetector
|
|||
}
|
||||
|
||||
$deviceResult = $cacheItem->get();
|
||||
assert($deviceResult instanceof DeviceResult);
|
||||
|
||||
$this->deviceResults[$userAgentHash] = $deviceResult;
|
||||
|
||||
return $deviceResult;
|
||||
|
|
Loading…
Reference in New Issue