mirror of
https://code.castopod.org/adaures/castopod
synced 2025-06-06 18:31:05 +00:00
fix(websub): add missing misc helper import
+ add checks before clearing episode cache
This commit is contained in:
parent
19fcb9b0f3
commit
855aacce0b
@ -395,7 +395,20 @@ class EpisodeModel extends Model
|
|||||||
*/
|
*/
|
||||||
public function clearCache(array $data): array
|
public function clearCache(array $data): array
|
||||||
{
|
{
|
||||||
$episode = (new self())->find(is_array($data['id']) ? $data['id'][0] : $data['id']);
|
/** @var int|null $episodeId */
|
||||||
|
$episodeId = is_array($data['id']) ? $data['id'][0] : $data['id'];
|
||||||
|
|
||||||
|
if ($episodeId === null) {
|
||||||
|
// Multiple episodes have been updated, do nothing
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var ?Episode $episode */
|
||||||
|
$episode = (new self())->find($episodeId);
|
||||||
|
|
||||||
|
if (! $episode instanceof Episode) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
// delete podcast cache
|
// delete podcast cache
|
||||||
cache()
|
cache()
|
||||||
@ -430,9 +443,22 @@ class EpisodeModel extends Model
|
|||||||
*/
|
*/
|
||||||
protected function writeEnclosureMetadata(array $data): array
|
protected function writeEnclosureMetadata(array $data): array
|
||||||
{
|
{
|
||||||
helper('id3');
|
/** @var int|null $episodeId */
|
||||||
|
$episodeId = is_array($data['id']) ? $data['id'][0] : $data['id'];
|
||||||
|
|
||||||
$episode = (new self())->find(is_array($data['id']) ? $data['id'][0] : $data['id']);
|
if ($episodeId === null) {
|
||||||
|
// Multiple episodes have been updated, do nothing
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var ?Episode $episode */
|
||||||
|
$episode = (new self())->find($episodeId);
|
||||||
|
|
||||||
|
if (! $episode instanceof Episode) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
helper('id3');
|
||||||
|
|
||||||
write_audio_file_tags($episode);
|
write_audio_file_tags($episode);
|
||||||
|
|
||||||
|
@ -24,20 +24,22 @@ class WebSubController extends Controller
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
helper('misc');
|
||||||
|
|
||||||
// get all podcasts that haven't been published yet
|
// get all podcasts that haven't been published yet
|
||||||
// or having a published episode that hasn't been pushed yet
|
// or having a published episode that hasn't been pushed yet
|
||||||
$podcastModel = new PodcastModel();
|
$podcastModel = new PodcastModel();
|
||||||
$podcasts = $podcastModel
|
$podcastModel->builder()
|
||||||
->distinct()
|
|
||||||
->select('podcasts.*')
|
->select('podcasts.*')
|
||||||
|
->distinct()
|
||||||
->join('episodes', 'podcasts.id = episodes.podcast_id', 'left outer')
|
->join('episodes', 'podcasts.id = episodes.podcast_id', 'left outer')
|
||||||
->where('podcasts.is_published_on_hubs', false)
|
->where('podcasts.is_published_on_hubs', false)
|
||||||
->where('`' . $podcastModel->db->getPrefix() . 'podcasts`.`published_at` <= UTC_TIMESTAMP()', null, false)
|
->where('`' . $podcastModel->db->getPrefix() . 'podcasts`.`published_at` <= UTC_TIMESTAMP()', null, false)
|
||||||
->orGroupStart()
|
->orGroupStart()
|
||||||
->where('episodes.is_published_on_hubs', false)
|
->where('episodes.is_published_on_hubs', false)
|
||||||
->where('`' . $podcastModel->db->getPrefix() . 'episodes`.`published_at` <= UTC_TIMESTAMP()', null, false)
|
->where('`' . $podcastModel->db->getPrefix() . 'episodes`.`published_at` <= UTC_TIMESTAMP()', null, false)
|
||||||
->groupEnd()
|
->groupEnd();
|
||||||
->findAll();
|
$podcasts = $podcastModel->findAll();
|
||||||
|
|
||||||
if ($podcasts === []) {
|
if ($podcasts === []) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user