From 1253096197a0d30692bdafa7152f250cd9a71acf Mon Sep 17 00:00:00 2001 From: Yassine Doghri <yassine@doghri.fr> Date: Tue, 15 Mar 2022 10:14:29 +0000 Subject: [PATCH] fix: add explicit int conversion when formatting episode duration --- themes/cp_admin/episode/list.php | 4 ++-- themes/cp_admin/episode/publish.php | 4 ++-- themes/cp_admin/episode/publish_edit.php | 4 ++-- themes/cp_admin/episode/video_clips_list.php | 2 +- themes/cp_app/episode/_layout.php | 2 +- themes/cp_app/episode/_partials/card.php | 2 +- themes/cp_app/episode/_partials/preview_card.php | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/themes/cp_admin/episode/list.php b/themes/cp_admin/episode/list.php index 6ffd2214aa..b491ea9613 100644 --- a/themes/cp_admin/episode/list.php +++ b/themes/cp_admin/episode/list.php @@ -29,9 +29,9 @@ 'cell' => function ($episode, $podcast) { return '<div class="flex">' . '<div class="relative flex-shrink-0 mr-2">' . - '<time class="absolute px-1 text-xs font-semibold text-white rounded bottom-2 right-2 bg-black/50" datetime="PT<?= $episode->audio->duration ?>S">' . + '<time class="absolute px-1 text-xs font-semibold text-white rounded bottom-2 right-2 bg-black/50" datetime="PT' . round($episode->audio->duration, 3) . 'S">' . format_duration( - $episode->audio->duration, + (int) $episode->audio->duration, ) . '</time>' . '<img src="' . $episode->cover->thumbnail_url . '" alt="' . esc($episode->title) . '" class="object-cover w-20 rounded-lg shadow-inner aspect-square" loading="lazy" />' . diff --git a/themes/cp_admin/episode/publish.php b/themes/cp_admin/episode/publish.php index 3c3c105414..e3a5e22351 100644 --- a/themes/cp_admin/episode/publish.php +++ b/themes/cp_admin/episode/publish.php @@ -54,8 +54,8 @@ ) ?> </div> <div class="text-xs text-skin-muted"> - <time datetime="PT<?= $episode->audio->duration ?>S"> - <?= format_duration($episode->audio->duration) ?> + <time datetime="PT<?= round($episode->audio->duration, 3) ?>S"> + <?= format_duration((int) $episode->audio->duration) ?> </time> </div> </a> diff --git a/themes/cp_admin/episode/publish_edit.php b/themes/cp_admin/episode/publish_edit.php index 79a9a461ef..7144875343 100644 --- a/themes/cp_admin/episode/publish_edit.php +++ b/themes/cp_admin/episode/publish_edit.php @@ -58,8 +58,8 @@ <div class="text-xs text-skin-muted"> <?= relative_time($episode->published_at) ?> <span class="mx-1">•</span> - <time datetime="PT<?= $episode->audio->duration ?>S"> - <?= format_duration($episode->audio->duration) ?> + <time datetime="PT<?= round($episode->audio->duration, 3) ?>S"> + <?= format_duration((int) $episode->audio->duration) ?> </time> </div> </a> diff --git a/themes/cp_admin/episode/video_clips_list.php b/themes/cp_admin/episode/video_clips_list.php index 474233b160..c55fcb54b0 100644 --- a/themes/cp_admin/episode/video_clips_list.php +++ b/themes/cp_admin/episode/video_clips_list.php @@ -72,7 +72,7 @@ use CodeIgniter\I18n\Time; if ($videoClip->job_started_at !== null) { if ($videoClip->job_ended_at !== null) { $duration = '<div class="flex flex-col text-xs gap-y-1">' . - '<div class="inline-flex items-center font-mono gap-x-1"><Icon glyph="timer" class="text-sm text-gray-400" />' . format_duration($videoClip->job_duration, true) . '</div>' . + '<div class="inline-flex items-center font-mono gap-x-1"><Icon glyph="timer" class="text-sm text-gray-400" />' . format_duration((int) $videoClip->job_duration, true) . '</div>' . '<div class="inline-flex items-center gap-x-1"><Icon glyph="calendar" class="text-sm text-gray-400" />' . relative_time($videoClip->job_ended_at) . '</div>' . '</div>'; } else { diff --git a/themes/cp_app/episode/_layout.php b/themes/cp_app/episode/_layout.php index aa047ddb3f..fd6b02a740 100644 --- a/themes/cp_app/episode/_layout.php +++ b/themes/cp_app/episode/_layout.php @@ -125,7 +125,7 @@ <?= relative_time($episode->published_at) ?> <span class="mx-1">•</span> <time datetime="PT<?= round($episode->audio->duration, 3) ?>S"> - <?= format_duration_symbol($episode->audio->duration) ?> + <?= format_duration_symbol((int) $episode->audio->duration) ?> </time> </div> </div> diff --git a/themes/cp_app/episode/_partials/card.php b/themes/cp_app/episode/_partials/card.php index 00a26425b7..7bfd5e7c28 100644 --- a/themes/cp_app/episode/_partials/card.php +++ b/themes/cp_app/episode/_partials/card.php @@ -1,7 +1,7 @@ <article class="flex w-full p-4 shadow bg-elevated rounded-conditional-2xl gap-x-2"> <div class="relative"> <time class="absolute px-1 text-xs font-semibold text-white rounded bottom-2 right-2 bg-black/75" datetime="PT<?= round($episode->audio->duration, 3) ?>S"> - <?= format_duration($episode->audio->duration) ?> + <?= format_duration((int) $episode->audio->duration) ?> </time> <img src="<?= $episode->cover ->thumbnail_url ?>" alt="<?= esc($episode->title) ?>" class="object-cover w-20 rounded-lg shadow-inner aspect-square" loading="lazy" /> diff --git a/themes/cp_app/episode/_partials/preview_card.php b/themes/cp_app/episode/_partials/preview_card.php index da0943d520..7bcd153029 100644 --- a/themes/cp_app/episode/_partials/preview_card.php +++ b/themes/cp_app/episode/_partials/preview_card.php @@ -1,7 +1,7 @@ <div class="flex items-center border-y border-subtle"> <div class="relative"> <time class="absolute px-1 text-sm font-semibold text-white rounded bg-black/75 bottom-2 right-2" datetime="PT<?= round($episode->audio->duration, 3) ?>S"> - <?= format_duration($episode->audio->duration) ?> + <?= format_duration((int) $episode->audio->duration) ?> </time> <img src="<?= $episode->cover->thumbnail_url ?>" -- GitLab