chore: update CI to v4.6.3 + all php and js dependencies

This commit is contained in:
Yassine Doghri 2025-08-25 18:09:41 +00:00
commit 346c00e7b5
206 changed files with 6239 additions and 5336 deletions

View file

@ -20,9 +20,11 @@ class DashboardController extends BaseController
public function index(): string
{
$podcastsData = [];
$podcastsCount = (new PodcastModel())->builder()
$podcastsCount = new PodcastModel()
->builder()
->countAll();
$podcastsLastPublishedAt = (new PodcastModel())->builder()
$podcastsLastPublishedAt = new PodcastModel()
->builder()
->selectMax('published_at', 'last_published_at')
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
->get()
@ -33,9 +35,11 @@ class DashboardController extends BaseController
);
$episodesData = [];
$episodesCount = (new EpisodeModel())->builder()
$episodesCount = new EpisodeModel()
->builder()
->countAll();
$episodesLastPublishedAt = (new EpisodeModel())->builder()
$episodesLastPublishedAt = new EpisodeModel()
->builder()
->selectMax('published_at', 'last_published_at')
->where('`published_at` <= UTC_TIMESTAMP()', null, false)
->get()
@ -45,7 +49,8 @@ class DashboardController extends BaseController
$episodesLastPublishedAt,
);
$totalUploaded = (new MediaModel())->builder()
$totalUploaded = new MediaModel()
->builder()
->selectSum('file_size')
->get()
->getResultArray()[0];
@ -66,7 +71,8 @@ class DashboardController extends BaseController
$onlyPodcastId = null;
if ($podcastsData['number_of_podcasts'] === 1) {
$onlyPodcastId = (new PodcastModel())->first()
$onlyPodcastId = new PodcastModel()
->first()
->id;
}

View file

@ -40,7 +40,7 @@ class EpisodeController extends BaseController
}
if (count($params) === 1) {
if (! ($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast) {
if (! ($podcast = new PodcastModel()->getPodcastById((int) $params[0])) instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
}
@ -48,7 +48,7 @@ class EpisodeController extends BaseController
}
if (
! ($episode = (new EpisodeModel())->getEpisodeById((int) $params[1])) instanceof Episode
! ($episode = new EpisodeModel()->getEpisodeById((int) $params[1])) instanceof Episode
) {
throw PageNotFoundException::forPageNotFound();
}
@ -127,11 +127,13 @@ class EpisodeController extends BaseController
{
helper(['form']);
$currentSeasonNumber = (new EpisodeModel())->getCurrentSeasonNumber($podcast->id);
$currentSeasonNumber = new EpisodeModel()
->getCurrentSeasonNumber($podcast->id);
$data = [
'podcast' => $podcast,
'currentSeasonNumber' => $currentSeasonNumber,
'nextEpisodeNumber' => (new EpisodeModel())->getNextEpisodeNumber($podcast->id, $currentSeasonNumber),
'nextEpisodeNumber' => new EpisodeModel()
->getNextEpisodeNumber($podcast->id, $currentSeasonNumber),
];
$this->setHtmlHead(lang('Episode.create'));
@ -165,7 +167,7 @@ class EpisodeController extends BaseController
$validData = $this->validator->getValidated();
if ((new EpisodeModel())
if (new EpisodeModel()
->where([
'slug' => $validData['slug'],
'podcast_id' => $podcast->id,
@ -315,7 +317,8 @@ class EpisodeController extends BaseController
($transcriptRemoteUrl = $this->request->getPost('transcript_remote_url')) &&
(($transcriptFile = $episode->transcript_id) !== null)
) {
(new MediaModel())->deleteMedia($episode->transcript);
new MediaModel()
->deleteMedia($episode->transcript);
}
$episode->transcript_remote_url = $transcriptRemoteUrl === '' ? null : $transcriptRemoteUrl;
@ -333,7 +336,8 @@ class EpisodeController extends BaseController
($chaptersRemoteUrl = $this->request->getPost('chapters_remote_url')) &&
(($chaptersFile = $episode->chapters) instanceof Chapters)
) {
(new MediaModel())->deleteMedia($episode->chapters);
new MediaModel()
->deleteMedia($episode->chapters);
}
$episode->chapters_remote_url = $chaptersRemoteUrl === '' ? null : $chaptersRemoteUrl;
@ -502,7 +506,7 @@ class EpisodeController extends BaseController
$data = [
'podcast' => $episode->podcast,
'episode' => $episode,
'post' => (new PostModel())
'post' => new PostModel()
->where([
'actor_id' => $episode->podcast->actor_id,
'episode_id' => $episode->id,
@ -571,7 +575,8 @@ class EpisodeController extends BaseController
$episode->published_at = Time::now();
}
$post = (new PostModel())->getPostById($this->request->getPost('post_id'));
$post = new PostModel()
->getPostById($this->request->getPost('post_id'));
if ($post instanceof Post) {
$post->message = $this->request->getPost('message');
@ -761,7 +766,7 @@ class EpisodeController extends BaseController
$db->transStart();
$allPostsLinkedToEpisode = (new PostModel())
$allPostsLinkedToEpisode = new PostModel()
->where([
'episode_id' => $episode->id,
'in_reply_to_id' => null,
@ -769,17 +774,19 @@ class EpisodeController extends BaseController
])
->findAll();
foreach ($allPostsLinkedToEpisode as $post) {
(new PostModel())->removePost($post);
new PostModel()
->removePost($post);
}
$allCommentsLinkedToEpisode = (new EpisodeCommentModel())
$allCommentsLinkedToEpisode = new EpisodeCommentModel()
->where([
'episode_id' => $episode->id,
'in_reply_to_id' => null,
])
->findAll();
foreach ($allCommentsLinkedToEpisode as $comment) {
(new EpisodeCommentModel())->removeComment($comment);
new EpisodeCommentModel()
->removeComment($comment);
}
// set episode published_at to null to unpublish
@ -795,9 +802,10 @@ class EpisodeController extends BaseController
}
// set podcast is_published_on_hubs to false to trigger websub push
(new PodcastModel())->update($episode->podcast_id, [
'is_published_on_hubs' => 0,
]);
new PodcastModel()
->update($episode->podcast_id, [
'is_published_on_hubs' => 0,
]);
$db->transComplete();

View file

@ -27,7 +27,7 @@ class EpisodePersonController extends BaseController
}
if (count($params) === 1) {
if (! ($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast) {
if (! ($podcast = new PodcastModel()->getPodcastById((int) $params[0])) instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
}
@ -35,7 +35,7 @@ class EpisodePersonController extends BaseController
}
if (
! ($episode = (new EpisodeModel())->getEpisodeById((int) $params[1])) instanceof Episode
! ($episode = new EpisodeModel()->getEpisodeById((int) $params[1])) instanceof Episode
) {
throw PageNotFoundException::forPageNotFound();
}
@ -51,10 +51,12 @@ class EpisodePersonController extends BaseController
helper('form');
$data = [
'episode' => $episode,
'podcast' => $episode->podcast,
'personOptions' => (new PersonModel())->getPersonOptions(),
'taxonomyOptions' => (new PersonModel())->getTaxonomyOptions(),
'episode' => $episode,
'podcast' => $episode->podcast,
'personOptions' => new PersonModel()
->getPersonOptions(),
'taxonomyOptions' => new PersonModel()
->getTaxonomyOptions(),
];
$this->setHtmlHead(lang('Person.episode_form.title'));
@ -80,19 +82,21 @@ class EpisodePersonController extends BaseController
$validData = $this->validator->getValidated();
(new PersonModel())->addEpisodePersons(
$episode->podcast_id,
$episode->id,
$validData['persons'],
$this->request->getPost('roles') ?? [],
);
new PersonModel()
->addEpisodePersons(
$episode->podcast_id,
$episode->id,
$validData['persons'],
$this->request->getPost('roles') ?? [],
);
return redirect()->back();
}
public function deleteAction(Episode $episode, string $personId): RedirectResponse
{
(new PersonModel())->removePersonFromEpisode($episode->podcast_id, $episode->id, (int) $personId);
new PersonModel()
->removePersonFromEpisode($episode->podcast_id, $episode->id, (int) $personId);
return redirect()->back();
}

View file

@ -32,7 +32,7 @@ class NotificationController extends BaseController
}
if (
! ($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast
! ($podcast = new PodcastModel()->getPodcastById((int) $params[0])) instanceof Podcast
) {
throw PageNotFoundException::forPageNotFound();
}
@ -41,7 +41,7 @@ class NotificationController extends BaseController
if (count($params) > 1) {
if (
! ($notification = (new NotificationModel())->find($params[1])) instanceof Notification
! ($notification = new NotificationModel()->find($params[1])) instanceof Notification
) {
throw PageNotFoundException::forPageNotFound();
}
@ -54,7 +54,8 @@ class NotificationController extends BaseController
public function list(Podcast $podcast): string
{
$notifications = (new NotificationModel())->where('target_actor_id', $podcast->actor_id)
$notifications = new NotificationModel()
->where('target_actor_id', $podcast->actor_id)
->orderBy('created_at', 'desc');
$data = [
@ -72,13 +73,15 @@ class NotificationController extends BaseController
public function markAllAsReadAction(Podcast $podcast): RedirectResponse
{
$notifications = (new NotificationModel())->where('target_actor_id', $podcast->actor_id)
$notifications = new NotificationModel()
->where('target_actor_id', $podcast->actor_id)
->where('read_at', null)
->findAll();
foreach ($notifications as $notification) {
$notification->read_at = new Time('now');
(new NotificationModel())->update($notification->id, $notification);
new NotificationModel()
->update($notification->id, $notification);
}
return redirect()->back();
@ -94,7 +97,8 @@ class NotificationController extends BaseController
return redirect()->route('podcast-activity', [esc($podcast->handle)]);
}
$post = (new PostModel())->getPostById($notification->post_id);
$post = new PostModel()
->getPostById($notification->post_id);
return redirect()->route('post', [$podcast->handle, $post->id]);
}

View file

@ -23,7 +23,7 @@ class PageController extends BaseController
return $this->{$method}();
}
if (($page = (new PageModel())->find($params[0])) instanceof Page) {
if (($page = new PageModel()->find($params[0])) instanceof Page) {
return $this->{$method}($page);
}
@ -34,7 +34,8 @@ class PageController extends BaseController
{
$this->setHtmlHead(lang('Page.all_pages'));
$data = [
'pages' => (new PageModel())->findAll(),
'pages' => new PageModel()
->findAll(),
];
return view('page/list', $data);
@ -113,7 +114,8 @@ class PageController extends BaseController
public function deleteAction(Page $page): RedirectResponse
{
(new PageModel())->delete($page->id);
new PageModel()
->delete($page->id);
return redirect()->route('page-list');
}

View file

@ -25,7 +25,7 @@ class PersonController extends BaseController
}
if (
($person = (new PersonModel())->getPersonById((int) $params[0])) instanceof Person
($person = new PersonModel()->getPersonById((int) $params[0])) instanceof Person
) {
return $this->{$method}($person);
}
@ -36,7 +36,8 @@ class PersonController extends BaseController
public function list(): string
{
$data = [
'persons' => (new PersonModel())->orderBy('full_name')
'persons' => new PersonModel()
->orderBy('full_name')
->findAll(),
];
@ -157,10 +158,12 @@ class PersonController extends BaseController
{
if ($person->avatar_id !== null) {
// delete avatar to prevent collision if recreating person
(new MediaModel())->deleteMedia($person->avatar);
new MediaModel()
->deleteMedia($person->avatar);
}
(new PersonModel())->delete($person->id);
new PersonModel()
->delete($person->id);
return redirect()->route('person-list')
->with('message', lang('Person.messages.deleteSuccess'));

View file

@ -45,7 +45,7 @@ class PodcastController extends BaseController
}
if (
($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast
($podcast = new PodcastModel()->getPodcastById((int) $params[0])) instanceof Podcast
) {
return $this->{$method}($podcast);
}
@ -57,7 +57,8 @@ class PodcastController extends BaseController
{
if (auth()->user()->can('podcasts.view')) {
$data = [
'podcasts' => (new PodcastModel())->findAll(),
'podcasts' => new PodcastModel()
->findAll(),
];
} else {
$data = [
@ -177,8 +178,10 @@ class PodcastController extends BaseController
{
helper(['form', 'misc']);
$languageOptions = (new LanguageModel())->getLanguageOptions();
$categoryOptions = (new CategoryModel())->getCategoryOptions();
$languageOptions = new LanguageModel()
->getLanguageOptions();
$categoryOptions = new CategoryModel()
->getCategoryOptions();
$data = [
'languageOptions' => $languageOptions,
@ -251,10 +254,8 @@ class PodcastController extends BaseController
add_podcast_group(auth()->user(), (int) $newPodcastId, setting('AuthGroups.mostPowerfulPodcastGroup'));
// set Podcast categories
(new CategoryModel())->setPodcastCategories(
(int) $newPodcastId,
$this->request->getPost('other_categories') ?? [],
);
new CategoryModel()
->setPodcastCategories((int) $newPodcastId, $this->request->getPost('other_categories') ?? []);
$db->transComplete();
@ -268,8 +269,10 @@ class PodcastController extends BaseController
{
helper('form');
$languageOptions = (new LanguageModel())->getLanguageOptions();
$categoryOptions = (new CategoryModel())->getCategoryOptions();
$languageOptions = new LanguageModel()
->getLanguageOptions();
$categoryOptions = new CategoryModel()
->getCategoryOptions();
$data = [
'podcast' => $podcast,
@ -346,10 +349,8 @@ class PodcastController extends BaseController
}
// set Podcast categories
(new CategoryModel())->setPodcastCategories(
$podcast->id,
$this->request->getPost('other_categories') ?? [],
);
new CategoryModel()
->setPodcastCategories($podcast->id, $this->request->getPost('other_categories') ?? []);
// New feed url redirect
service('settings')
@ -385,18 +386,21 @@ class PodcastController extends BaseController
->with('errors', $mediaModel->errors());
}
(new PodcastModel())->clearCache([
'id' => $podcast->id,
]);
new PodcastModel()
->clearCache([
'id' => $podcast->id,
]);
// remove banner url from actor
$actor = (new ActorModel())->getActorById($podcast->actor_id);
$actor = new ActorModel()
->getActorById($podcast->actor_id);
if ($actor instanceof Actor) {
$actor->cover_image_url = null;
$actor->cover_image_mimetype = null;
(new ActorModel())->update($actor->id, $actor);
new ActorModel()
->update($actor->id, $actor);
}
$db->transComplete();
@ -406,7 +410,7 @@ class PodcastController extends BaseController
public function latestEpisodesView(int $limit, int $podcastId): string
{
$episodes = (new EpisodeModel())
$episodes = new EpisodeModel()
->where('podcast_id', $podcastId)
->orderBy('-`published_at`', '', false)
->orderBy('created_at', 'desc')
@ -414,7 +418,8 @@ class PodcastController extends BaseController
return view('podcast/latest_episodes', [
'episodes' => $episodes,
'podcast' => (new PodcastModel())->getPodcastById($podcastId),
'podcast' => new PodcastModel()
->getPodcastById($podcastId),
]);
}
@ -451,7 +456,8 @@ class PodcastController extends BaseController
$db->transStart();
//delete podcast episodes
$podcastEpisodes = (new EpisodeModel())->where('podcast_id', $podcast->id)
$podcastEpisodes = new EpisodeModel()
->where('podcast_id', $podcast->id)
->findAll();
foreach ($podcastEpisodes as $podcastEpisode) {
@ -669,7 +675,7 @@ class PodcastController extends BaseController
}
}
$episodes = (new EpisodeModel())
$episodes = new EpisodeModel()
->where('podcast_id', $podcast->id)
->where('published_at !=', null)
->findAll();
@ -686,7 +692,8 @@ class PodcastController extends BaseController
->with('errors', $episodeModel->errors());
}
$post = (new PostModel())->where('episode_id', $episode->id)
$post = new PostModel()
->where('episode_id', $episode->id)
->first();
if ($post instanceof Post) {
@ -722,7 +729,7 @@ class PodcastController extends BaseController
$data = [
'podcast' => $podcast,
'post' => (new PostModel())
'post' => new PostModel()
->where([
'actor_id' => $podcast->actor_id,
'episode_id' => null,
@ -783,7 +790,7 @@ class PodcastController extends BaseController
$podcast->published_at = Time::now();
}
$post = (new PostModel())
$post = new PostModel()
->where([
'actor_id' => $podcast->actor_id,
'episode_id' => null,
@ -837,7 +844,7 @@ class PodcastController extends BaseController
}
}
$episodes = (new EpisodeModel())
$episodes = new EpisodeModel()
->where('podcast_id', $podcast->id)
->where('published_at !=', null)
->findAll();
@ -854,7 +861,8 @@ class PodcastController extends BaseController
->with('errors', $episodeModel->errors());
}
$post = (new PostModel())->where('episode_id', $episode->id)
$post = new PostModel()
->where('episode_id', $episode->id)
->first();
if ($post instanceof Post) {
@ -904,7 +912,7 @@ class PodcastController extends BaseController
$postModel->removePost($post);
}
$episodes = (new EpisodeModel())
$episodes = new EpisodeModel()
->where('podcast_id', $podcast->id)
->where('published_at !=', null)
->findAll();

View file

@ -27,7 +27,7 @@ class PodcastPersonController extends BaseController
}
if (
($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast
($podcast = new PodcastModel()->getPodcastById((int) $params[0])) instanceof Podcast
) {
unset($params[0]);
return $this->{$method}($podcast, ...$params);
@ -41,10 +41,13 @@ class PodcastPersonController extends BaseController
helper('form');
$data = [
'podcast' => $podcast,
'podcastPersons' => (new PersonModel())->getPodcastPersons($podcast->id),
'personOptions' => (new PersonModel())->getPersonOptions(),
'taxonomyOptions' => (new PersonModel())->getTaxonomyOptions(),
'podcast' => $podcast,
'podcastPersons' => new PersonModel()
->getPodcastPersons($podcast->id),
'personOptions' => new PersonModel()
->getPersonOptions(),
'taxonomyOptions' => new PersonModel()
->getTaxonomyOptions(),
];
$this->setHtmlHead(lang('Person.podcast_form.title'));
@ -69,18 +72,16 @@ class PodcastPersonController extends BaseController
$validData = $this->validator->getValidated();
(new PersonModel())->addPodcastPersons(
$podcast->id,
$validData['persons'],
$this->request->getPost('roles') ?? [],
);
new PersonModel()
->addPodcastPersons($podcast->id, $validData['persons'], $this->request->getPost('roles') ?? []);
return redirect()->back();
}
public function deleteAction(Podcast $podcast, string $personId): RedirectResponse
{
(new PersonModel())->removePersonFromPodcast($podcast->id, (int) $personId);
new PersonModel()
->removePersonFromPodcast($podcast->id, (int) $personId);
return redirect()->back();
}

View file

@ -136,7 +136,8 @@ class SettingsController extends BaseController
public function regenerateImagesAction(): RedirectResponse
{
/** @var Podcast[] $allPodcasts */
$allPodcasts = (new PodcastModel())->findAll();
$allPodcasts = new PodcastModel()
->findAll();
/** @var FileManagerInterface $fileManager */
$fileManager = service('file_manager');
@ -158,7 +159,8 @@ class SettingsController extends BaseController
$fileManager->deletePersonImagesSizes();
$persons = (new PersonModel())->findAll();
$persons = new PersonModel()
->findAll();
foreach ($persons as $person) {
if ($person->avatar_id !== null) {
$person->avatar->saveSizes();
@ -172,16 +174,26 @@ class SettingsController extends BaseController
{
if ($this->request->getPost('reset_counts') === 'yes') {
// recalculate fediverse counts
(new ActorModel())->resetFollowersCount();
(new ActorModel())->resetPostsCount();
(new PostModel())->setEpisodeIdForRepliesOfEpisodePosts();
(new PostModel())->resetFavouritesCount();
(new PostModel())->resetReblogsCount();
(new PostModel())->resetRepliesCount();
(new EpisodeModel())->resetCommentsCount();
(new EpisodeModel())->resetPostsCount();
(new EpisodeCommentModel())->resetLikesCount();
(new EpisodeCommentModel())->resetRepliesCount();
new ActorModel()
->resetFollowersCount();
new ActorModel()
->resetPostsCount();
new PostModel()
->setEpisodeIdForRepliesOfEpisodePosts();
new PostModel()
->resetFavouritesCount();
new PostModel()
->resetReblogsCount();
new PostModel()
->resetRepliesCount();
new EpisodeModel()
->resetCommentsCount();
new EpisodeModel()
->resetPostsCount();
new EpisodeCommentModel()
->resetLikesCount();
new EpisodeCommentModel()
->resetRepliesCount();
}
if ($this->request->getPost('clear_cache') === 'yes') {
@ -190,7 +202,8 @@ class SettingsController extends BaseController
if ($this->request->getPost('rename_episodes_files') === 'yes') {
/** @var Audio[] $allAudio */
$allAudio = (new MediaModel('audio'))->getAllOfType();
$allAudio = new MediaModel('audio')
->getAllOfType();
foreach ($allAudio as $audio) {
$audio->rename();

View file

@ -29,7 +29,7 @@ class SoundbiteController extends BaseController
}
if (count($params) === 1) {
if (! ($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast) {
if (! ($podcast = new PodcastModel()->getPodcastById((int) $params[0])) instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
}
@ -37,7 +37,7 @@ class SoundbiteController extends BaseController
}
if (
! ($episode = (new EpisodeModel())->getEpisodeById((int) $params[1])) instanceof Episode
! ($episode = new EpisodeModel()->getEpisodeById((int) $params[1])) instanceof Episode
) {
throw PageNotFoundException::forPageNotFound();
}
@ -50,7 +50,7 @@ class SoundbiteController extends BaseController
public function list(Episode $episode): string
{
$soundbitesBuilder = (new ClipModel('audio'))
$soundbitesBuilder = new ClipModel('audio')
->where([
'podcast_id' => $episode->podcast_id,
'episode_id' => $episode->id,
@ -137,7 +137,8 @@ class SoundbiteController extends BaseController
public function deleteAction(Episode $episode, string $soundbiteId): RedirectResponse
{
$soundbite = (new ClipModel())->getSoundbiteById((int) $soundbiteId);
$soundbite = new ClipModel()
->getSoundbiteById((int) $soundbiteId);
if (! $soundbite instanceof Soundbite) {
throw PageNotFoundException::forPageNotFound();
@ -145,9 +146,11 @@ class SoundbiteController extends BaseController
if ($soundbite->media === null) {
// delete Clip directly
(new ClipModel())->deleteSoundbite($episode->podcast_id, $episode->id, $soundbite->id);
new ClipModel()
->deleteSoundbite($episode->podcast_id, $episode->id, $soundbite->id);
} else {
(new ClipModel())->clearSoundbiteCache($episode->podcast_id, $episode->id, $soundbite->id);
new ClipModel()
->clearSoundbiteCache($episode->podcast_id, $episode->id, $soundbite->id);
$mediaModel = new MediaModel();
// delete the soundbite file, the clip will be deleted on cascade

View file

@ -30,7 +30,7 @@ class VideoClipsController extends BaseController
}
if (count($params) === 1) {
if (! ($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast) {
if (! ($podcast = new PodcastModel()->getPodcastById((int) $params[0])) instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
}
@ -38,7 +38,7 @@ class VideoClipsController extends BaseController
}
if (
! ($episode = (new EpisodeModel())->getEpisodeById((int) $params[1])) instanceof Episode
! ($episode = new EpisodeModel()->getEpisodeById((int) $params[1])) instanceof Episode
) {
throw PageNotFoundException::forPageNotFound();
}
@ -51,7 +51,7 @@ class VideoClipsController extends BaseController
public function list(Episode $episode): string
{
$videoClipsBuilder = (new ClipModel('video'))
$videoClipsBuilder = new ClipModel('video')
->where([
'podcast_id' => $episode->podcast_id,
'episode_id' => $episode->id,
@ -83,7 +83,8 @@ class VideoClipsController extends BaseController
public function view(Episode $episode, string $videoClipId): string
{
$videoClip = (new ClipModel())->getVideoClipById((int) $videoClipId);
$videoClip = new ClipModel()
->getVideoClipById((int) $videoClipId);
$data = [
'podcast' => $episode->podcast,
@ -176,7 +177,7 @@ class VideoClipsController extends BaseController
]);
// Check if video clip exists before inserting a new line
if ((new ClipModel())->doesVideoClipExist($videoClip)) {
if (new ClipModel()->doesVideoClipExist($videoClip)) {
// video clip already exists
return redirect()
->back()
@ -184,7 +185,8 @@ class VideoClipsController extends BaseController
->with('error', lang('VideoClip.messages.alreadyExistingError'));
}
(new ClipModel())->insert($videoClip);
new ClipModel()
->insert($videoClip);
return redirect()->route('video-clips-list', [$episode->podcast_id, $episode->id])->with(
'message',
@ -194,24 +196,27 @@ class VideoClipsController extends BaseController
public function retryAction(Episode $episode, string $videoClipId): RedirectResponse
{
$videoClip = (new ClipModel())->getVideoClipById((int) $videoClipId);
$videoClip = new ClipModel()
->getVideoClipById((int) $videoClipId);
if (! $videoClip instanceof VideoClip) {
throw PageNotFoundException::forPageNotFound();
}
(new ClipModel())->update($videoClip->id, [
'status' => 'queued',
'job_started_at' => null,
'job_ended_at' => null,
]);
new ClipModel()
->update($videoClip->id, [
'status' => 'queued',
'job_started_at' => null,
'job_ended_at' => null,
]);
return redirect()->back();
}
public function deleteAction(Episode $episode, string $videoClipId): RedirectResponse
{
$videoClip = (new ClipModel())->getVideoClipById((int) $videoClipId);
$videoClip = new ClipModel()
->getVideoClipById((int) $videoClipId);
if (! $videoClip instanceof VideoClip) {
throw PageNotFoundException::forPageNotFound();
@ -219,9 +224,11 @@ class VideoClipsController extends BaseController
if ($videoClip->media === null) {
// delete Clip directly
(new ClipModel())->deleteVideoClip($episode->podcast_id, $episode->id, $videoClip->id);
new ClipModel()
->deleteVideoClip($videoClip->id);
} else {
(new ClipModel())->clearVideoClipCache($videoClip->id);
new ClipModel()
->clearVideoClipCache($videoClip->id);
$mediaModel = new MediaModel();
// delete the videoClip file, the clip will be deleted on cascade

View file

@ -15,12 +15,11 @@ use App\Models\EpisodeModel;
use CodeIgniter\Controller;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\RedirectResponse;
use Deprecated;
class EpisodeAnalyticsController extends Controller
{
/**
* @deprecated Replaced by EpisodeAudioController::index method
*/
#[Deprecated(message: 'Replaced by EpisodeAudioController::index method')]
public function hit(string $base64EpisodeData, string ...$audioPath): RedirectResponse
{
$episodeData = unpack(
@ -32,7 +31,8 @@ class EpisodeAnalyticsController extends Controller
throw PageNotFoundException::forPageNotFound();
}
$episode = (new EpisodeModel())->getEpisodeById($episodeData['episodeId']);
$episode = new EpisodeModel()
->getEpisodeById($episodeData['episodeId']);
if (! $episode instanceof Episode) {
throw PageNotFoundException::forPageNotFound();

View file

@ -267,9 +267,8 @@ class AnalyticsPodcastModel extends Model
public function getDataTotalStorageByMonth(): array
{
if (! ($found = cache('analytics_total_storage_by_month'))) {
$found = (new MediaModel())->select(
'DATE_FORMAT(uploaded_at,"%Y-%m") as labels, ROUND(sum(file_size) / 1000000, 2) as `values`',
)
$found = new MediaModel()
->select('DATE_FORMAT(uploaded_at,"%Y-%m") as labels, ROUND(sum(file_size) / 1000000, 2) as `values`')
->groupBy('labels')
->orderBy('labels', 'ASC')
->findAll();

View file

@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Modules\Api\Rest\V1\Controllers;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\IncomingRequest;
/** @property IncomingRequest $request */
abstract class BaseApiController extends Controller
{
use ResponseTrait;
/**
* Instance of the main Request object.
*
* @var IncomingRequest
*/
protected $request;
}

View file

@ -11,16 +11,12 @@ use App\Entities\Post;
use App\Models\EpisodeModel;
use App\Models\PodcastModel;
use App\Models\PostModel;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\I18n\Time;
use Modules\Auth\Models\UserModel;
class EpisodeController extends Controller
class EpisodeController extends BaseApiController
{
use ResponseTrait;
public function __construct()
{
service('restApiExceptions')->initialize();
@ -50,6 +46,7 @@ class EpisodeController extends Controller
$builder->orderBy('episodes.created_at', 'desc');
}
/** @var array<string,mixed> $data */
$data = $builder->findAll(
(int) ($this->request->getGet('limit') ?? config('RestApi')->limit),
(int) $this->request->getGet('offset'),
@ -64,7 +61,8 @@ class EpisodeController extends Controller
public function view(int $id): ResponseInterface
{
$episode = (new EpisodeModel())->getEpisodeById($id);
$episode = new EpisodeModel()
->getEpisodeById($id);
if (! $episode instanceof Episode) {
return $this->failNotFound('Episode not found');
@ -96,7 +94,8 @@ class EpisodeController extends Controller
$podcastId = (int) $this->request->getPost('podcast_id');
$podcast = (new PodcastModel())->getPodcastById($podcastId);
$podcast = new PodcastModel()
->getPodcastById($podcastId);
if (! $podcast instanceof Podcast) {
return $this->failNotFound('Podcast not found');
@ -129,7 +128,7 @@ class EpisodeController extends Controller
$validData = $this->validator->getValidated();
if ((new EpisodeModel())
if (new EpisodeModel()
->where([
'slug' => $validData['slug'],
'podcast_id' => $podcast->id,
@ -187,7 +186,7 @@ class EpisodeController extends Controller
$episodeModel = new EpisodeModel();
if (($newEpisodeId = (int) $episodeModel->insert($newEpisode, true)) === 0) {
return $this->fail($episodeModel->errors(), 400);
return $this->fail(array_values($episodeModel->errors()), 400);
}
$episode = $episodeModel->find($newEpisodeId)
@ -278,12 +277,12 @@ class EpisodeController extends Controller
$postModel = new PostModel();
if (! $postModel->addPost($newPost)) {
$db->transRollback();
return $this->fail($postModel->errors(), 400);
return $this->fail(array_values($postModel->errors()), 400);
}
if (! $episodeModel->update($episode->id, $episode)) {
$db->transRollback();
return $this->fail($episodeModel->errors(), 400);
return $this->fail(array_values($episodeModel->errors()), 400);
}
$db->transComplete();

View file

@ -4,14 +4,10 @@ declare(strict_types=1);
namespace Modules\Api\Rest\V1\Controllers;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\ResponseInterface;
class ExceptionController extends Controller
class ExceptionController extends BaseApiController
{
use ResponseTrait;
public function notFound(): ResponseInterface
{
return $this->failNotFound('Podcast not found');

View file

@ -6,14 +6,10 @@ namespace Modules\Api\Rest\V1\Controllers;
use App\Entities\Podcast;
use App\Models\PodcastModel;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\ResponseInterface;
class PodcastController extends Controller
class PodcastController extends BaseApiController
{
use ResponseTrait;
public function __construct()
{
service('restApiExceptions')->initialize();
@ -21,7 +17,9 @@ class PodcastController extends Controller
public function list(): ResponseInterface
{
$data = (new PodcastModel())->findAll();
/** @var array<string,mixed> $data */
$data = new PodcastModel()
->findAll();
array_map(static function ($podcast): void {
self::mapPodcast($podcast);
}, $data);
@ -30,7 +28,8 @@ class PodcastController extends Controller
public function view(int $id): ResponseInterface
{
$podcast = (new PodcastModel())->getPodcastById($id);
$podcast = new PodcastModel()
->getPodcastById($id);
if (! $podcast instanceof Podcast) {
return $this->failNotFound('Podcast not found');
}

View file

@ -228,7 +228,8 @@ class AuthGroups extends ShieldAuthGroups
* For each podcast, include podcast groups, permissions, and matrix into $groups, $permissions, and $matrix
* attributes.
*/
$podcasts = (new PodcastModel())->findAll();
$podcasts = new PodcastModel()
->findAll();
foreach ($podcasts as $podcast) {
$this->generatePodcastAuthorizations($podcast->id);
}

View file

@ -7,7 +7,7 @@ namespace Modules\Auth\Config;
use CodeIgniter\Router\RouteCollection;
/**
* @var RouteCollection $routes
* @var RouteCollection
*/
service('auth')

View file

@ -30,7 +30,7 @@ class ContributorController extends BaseController
throw PageNotFoundException::forPageNotFound();
}
if (! ($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast) {
if (! ($podcast = new PodcastModel()->getPodcastById((int) $params[0])) instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
}
@ -40,7 +40,7 @@ class ContributorController extends BaseController
return $this->{$method}();
}
if (($this->contributor = (new UserModel())->getPodcastContributor(
if (($this->contributor = new UserModel()->getPodcastContributor(
(int) $params[1],
(int) $params[0],
)) instanceof User) {
@ -67,7 +67,8 @@ class ContributorController extends BaseController
{
$data = [
'podcast' => $this->podcast,
'contributor' => (new UserModel())->getPodcastContributor($this->contributor->id, $this->podcast->id),
'contributor' => new UserModel()
->getPodcastContributor($this->contributor->id, $this->podcast->id),
];
$this->setHtmlHead(lang('Contributor.view', [
@ -85,7 +86,8 @@ class ContributorController extends BaseController
{
helper('form');
$users = (new UserModel())->findAll();
$users = new UserModel()
->findAll();
$contributorOptions = array_reduce(
$users,
static function (array $result, User $user): array {
@ -128,7 +130,8 @@ class ContributorController extends BaseController
public function createAction(): RedirectResponse
{
/** @var User $user */
$user = (new UserModel())->find((int) $this->request->getPost('user'));
$user = new UserModel()
->find((int) $this->request->getPost('user'));
if (get_podcast_group($user, $this->podcast->id)) {
return redirect()

View file

@ -29,7 +29,7 @@ class UserController extends BaseController
return $this->{$method}();
}
if (($this->user = (new UserModel())->find($params[0])) instanceof User) {
if (($this->user = new UserModel()->find($params[0])) instanceof User) {
return $this->{$method}();
}
@ -39,7 +39,8 @@ class UserController extends BaseController
public function list(): string
{
$data = [
'users' => (new UserModel())->findAll(),
'users' => new UserModel()
->findAll(),
];
$this->setHtmlHead(lang('User.all_users'));
@ -280,7 +281,8 @@ class UserController extends BaseController
->with('errors', $this->validator->getErrors());
}
(new UserModel())->delete($this->user->id, true);
new UserModel()
->delete($this->user->id, true);
return redirect()
->route('user-list')

View file

@ -86,7 +86,8 @@ class PermissionFilter implements FilterInterface
if (is_numeric($podcastParam)) {
$podcastId = (int) $podcastParam;
} else {
$podcast = (new PodcastModel())->getPodcastByHandle($podcastParam);
$podcast = new PodcastModel()
->getPodcastByHandle($podcastParam);
if ($podcast instanceof Podcast) {
$podcastId = $podcast->id;
}

View file

@ -214,7 +214,8 @@ if (! function_exists('get_user_podcasts')) {
*/
function get_user_podcasts(User $user): array
{
return (new PodcastModel())->getUserPodcasts($user->id, get_user_podcast_ids($user));
return new PodcastModel()
->getUserPodcasts($user->id, get_user_podcast_ids($user));
}
}
@ -224,7 +225,8 @@ if (! function_exists('get_podcasts_user_can_interact_with')) {
*/
function get_podcasts_user_can_interact_with(User $user): array
{
$userPodcasts = (new PodcastModel())->getUserPodcasts($user->id, get_user_podcast_ids($user));
$userPodcasts = new PodcastModel()
->getUserPodcasts($user->id, get_user_podcast_ids($user));
$hasInteractAsPrivilege = interact_as_actor_id() === null;
@ -279,10 +281,8 @@ if (! function_exists('get_actor_ids_with_unread_notifications')) {
return [];
}
$unreadNotifications = (new NotificationModel())->whereIn(
'target_actor_id',
array_column($userPodcasts, 'actor_id'),
)
$unreadNotifications = new NotificationModel()
->whereIn('target_actor_id', array_column($userPodcasts, 'actor_id'))
->where('read_at', null)
->findAll();

View file

@ -70,7 +70,8 @@ class Notification extends UuidEntity
}
if (! $this->actor instanceof Actor) {
$this->actor = (new ActorModel())->getActorById($this->actor_id);
$this->actor = new ActorModel()
->getActorById($this->actor_id);
}
return $this->actor;
@ -83,7 +84,8 @@ class Notification extends UuidEntity
}
if (! $this->target_actor instanceof Actor) {
$this->target_actor = (new ActorModel())->getActorById($this->target_actor_id);
$this->target_actor = new ActorModel()
->getActorById($this->target_actor_id);
}
return $this->target_actor;
@ -96,7 +98,8 @@ class Notification extends UuidEntity
}
if (! $this->post instanceof Post) {
$this->post = (new PostModel())->getPostById($this->post_id);
$this->post = new PostModel()
->getPostById($this->post_id);
}
return $this->post;

View file

@ -45,7 +45,8 @@ class FediverseFilter implements FilterInterface
$payload = $request->getJSON();
$actorUri = $payload->actor;
$domain = (new URI($actorUri))->getHost();
$domain = new URI($actorUri)
->getHost();
// check first if domain is blocked
if (model('BlockedDomainModel', false)->isDomainBlocked($domain)) {
@ -61,7 +62,8 @@ class FediverseFilter implements FilterInterface
if (in_array('verify-signature', $params, true)) {
try {
// securityCheck: check activity signature before handling it
(new HttpSignature())->verify();
new HttpSignature()
->verify();
} catch (Exception) {
// Invalid HttpSignature (401 = unauthorized)
// TODO: show error message?

View file

@ -139,7 +139,8 @@ class ActivityModel extends UuidModel
protected function notify(array $data): array
{
/** @var ?Activity $activity */
$activity = (new self())->find(is_array($data['id']) ? $data['id'][0] : $data['id']);
$activity = new self()
->find(is_array($data['id']) ? $data['id'][0] : $data['id']);
if (! $activity instanceof Activity) {
return $data;
@ -155,35 +156,39 @@ class ActivityModel extends UuidModel
}
if ($activity->type === 'Follow') {
(new NotificationModel())->insert([
'actor_id' => $activity->actor_id,
'target_actor_id' => $activity->target_actor_id,
'activity_id' => $activity->id,
'type' => 'follow',
'created_at' => $activity->created_at,
]);
new NotificationModel()
->insert([
'actor_id' => $activity->actor_id,
'target_actor_id' => $activity->target_actor_id,
'activity_id' => $activity->id,
'type' => 'follow',
'created_at' => $activity->created_at,
]);
} elseif ($activity->type === 'Undo_Follow') {
(new NotificationModel())->builder()
new NotificationModel()
->builder()
->delete([
'actor_id' => $activity->actor_id,
'target_actor_id' => $activity->target_actor_id,
'type' => 'follow',
]);
} elseif (in_array($activity->type, ['Create', 'Like', 'Announce'], true) && $activity->post_id !== null) {
(new NotificationModel())->insert([
'actor_id' => $activity->actor_id,
'target_actor_id' => $activity->target_actor_id,
'post_id' => $activity->post_id,
'activity_id' => $activity->id,
'type' => match ($activity->type) {
'Create' => 'reply',
'Like' => 'like',
'Announce' => 'share',
},
'created_at' => $activity->created_at,
]);
new NotificationModel()
->insert([
'actor_id' => $activity->actor_id,
'target_actor_id' => $activity->target_actor_id,
'post_id' => $activity->post_id,
'activity_id' => $activity->id,
'type' => match ($activity->type) {
'Create' => 'reply',
'Like' => 'like',
'Announce' => 'share',
},
'created_at' => $activity->created_at,
]);
} elseif (in_array($activity->type, ['Undo_Like', 'Undo_Announce'], true) && $activity->post_id !== null) {
(new NotificationModel())->builder()
new NotificationModel()
->builder()
->delete([
'actor_id' => $activity->actor_id,
'target_actor_id' => $activity->target_actor_id,

View file

@ -117,7 +117,7 @@ class InstallController extends Controller
$db = db_connect();
// Check if instance owner has been created, meaning install was completed
if ($db->tableExists('users') && (new UserModel())->where('is_owner', true)
if ($db->tableExists('users') && new UserModel()->where('is_owner', true)
->first() instanceof User
) {
// if so, show a 404 page

View file

@ -116,12 +116,12 @@ class BaseMedia extends Entity
public function rename(): bool
{
$newFileKey = $this->file_directory . '/' . (new File(''))->getRandomName() . '.' . $this->file_extension;
$newFileKey = $this->file_directory . '/' . new File('')->getRandomName() . '.' . $this->file_extension;
$db = db_connect();
$db->transStart();
if (! (new MediaModel())->update($this->id, [
if (! new MediaModel()->update($this->id, [
'file_key' => $newFileKey,
])) {
return false;

View file

@ -25,13 +25,15 @@ class Generate extends BaseCommand
{
// get number of running clips to prevent from having too much running in parallel
// TODO: get the number of running ffmpeg processes directly from the machine?
$runningVideoClips = (new ClipModel())->getRunningVideoClipsCount();
$runningVideoClips = new ClipModel()
->getRunningVideoClipsCount();
if ($runningVideoClips >= config('Admin')->videoClipWorkers) {
return;
}
// get all clips that haven't been processed yet
$scheduledClips = (new ClipModel())->getScheduledVideoClips();
$scheduledClips = new ClipModel()
->getScheduledVideoClips();
if ($scheduledClips === []) {
return;
@ -45,13 +47,14 @@ class Generate extends BaseCommand
];
}
(new ClipModel())->updateBatch($data, 'id');
new ClipModel()
->updateBatch($data, 'id');
// Loop through clips to generate them
foreach ($scheduledClips as $scheduledClip) {
try {
// set clip to pending
(new ClipModel())
new ClipModel()
->update($scheduledClip->id, [
'status' => 'running',
'job_started_at' => Time::now(),
@ -86,11 +89,12 @@ class Generate extends BaseCommand
$clipModel->clearVideoClipCache($scheduledClip->id);
} catch (Exception $exception) {
(new ClipModel())->update($scheduledClip->id, [
'status' => 'failed',
'logs' => $exception,
'job_ended_at' => Time::now(),
]);
new ClipModel()
->update($scheduledClip->id, [
'status' => 'failed',
'logs' => $exception,
'job_ended_at' => Time::now(),
]);
}
}
}

View file

@ -28,7 +28,7 @@ class PlatformController extends BaseController
}
if (
! ($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast
! ($podcast = new PodcastModel()->getPodcastById((int) $params[0])) instanceof Podcast
) {
throw PageNotFoundException::forPageNotFound();
}
@ -51,7 +51,8 @@ class PlatformController extends BaseController
$data = [
'podcast' => $this->podcast,
'platformType' => $platformType,
'platforms' => (new PlatformModel())->getPlatformsWithData($this->podcast->id, $platformType),
'platforms' => new PlatformModel()
->getPlatformsWithData($this->podcast->id, $platformType),
];
$this->setHtmlHead(lang("Platforms.title.{$platformType}"));
@ -100,7 +101,8 @@ class PlatformController extends BaseController
public function removeAction(string $platformType, string $platformSlug): RedirectResponse
{
(new PlatformModel())->removePlatform($this->podcast->id, $platformType, $platformSlug);
new PlatformModel()
->removePlatform($this->podcast->id, $platformType, $platformSlug);
return redirect()
->back()

View file

@ -105,7 +105,8 @@ class PluginController extends BaseController
];
if ($podcastId !== null) {
$podcast = (new PodcastModel())->getPodcastById((int) $podcastId);
$podcast = new PodcastModel()
->getPodcastById((int) $podcastId);
if (! $podcast instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
@ -118,7 +119,8 @@ class PluginController extends BaseController
}
if ($episodeId !== null) {
$episode = (new EpisodeModel())->getEpisodeById((int) $episodeId);
$episode = new EpisodeModel()
->getEpisodeById((int) $episodeId);
if (! $episode instanceof Episode) {
throw PageNotFoundException::forPageNotFound();

View file

@ -358,7 +358,8 @@ abstract class BasePlugin implements PluginInterface
$environment = new Environment([
'html_input' => 'escape',
'allow_unsafe_links' => false,
'host' => (new URI(base_url()))->getHost(),
'host' => new URI(base_url())
->getHost(),
]);
$environment->addExtension(new CommonMarkCoreExtension());
@ -368,13 +369,15 @@ abstract class BasePlugin implements PluginInterface
$environment->addEventListener(
DocumentParsedEvent::class,
static function (DocumentParsedEvent $event): void {
(new ExternalLinkProcessor())->onDocumentParsed($event);
new ExternalLinkProcessor()
->onDocumentParsed($event);
},
);
$environment->addEventListener(
DocumentParsedEvent::class,
static function (DocumentParsedEvent $event): void {
(new ExternalImageProcessor())->onDocumentParsed($event);
new ExternalImageProcessor()
->onDocumentParsed($event);
},
);

View file

@ -39,6 +39,7 @@ class ExternalImageProcessor
$host = parse_url($url, PHP_URL_HOST);
// TODO: load from environment's config
return $host !== (new URI(base_url()))->getHost();
return $host !== new URI(base_url())
->getHost();
}
}

View file

@ -40,6 +40,7 @@ class ExternalLinkProcessor
$host = parse_url($url, PHP_URL_HOST);
// TODO: load from environment's config
return $host !== (new URI(base_url()))->getHost();
return $host !== new URI(base_url())
->getHost();
}
}

View file

@ -51,7 +51,10 @@ class PodcastImport extends BaseCommand
$importQueue = get_import_tasks();
$currentImport = current(
array_filter($importQueue, static fn ($task): bool => $task->status === TaskStatus::Running),
array_filter(
$importQueue,
static fn (PodcastImportTask $task): bool => $task->status === TaskStatus::Running,
),
);
if ($currentImport instanceof PodcastImportTask) {
@ -66,7 +69,10 @@ class PodcastImport extends BaseCommand
}
// Get the next queued import
$queuedImports = array_filter($importQueue, static fn ($task): bool => $task->status === TaskStatus::Queued);
$queuedImports = array_filter(
$importQueue,
static fn (PodcastImportTask $task): bool => $task->status === TaskStatus::Queued,
);
$nextImport = end($queuedImports);
if (! $nextImport instanceof PodcastImportTask) {
@ -77,7 +83,8 @@ class PodcastImport extends BaseCommand
$this->importTask = $nextImport;
// retrieve user who created import task
$user = (new UserModel())->find($this->importTask->created_by);
$user = new UserModel()
->find($this->importTask->created_by);
if (! $user instanceof User) {
throw new Exception('Could not retrieve user with ID: ' . $this->importTask->created_by);
@ -121,10 +128,12 @@ class PodcastImport extends BaseCommand
// check if podcast to be imported already exists by guid if exists or handle otherwise
$podcastGuid = $this->podcastFeed->channel->podcast_guid->getValue();
if ($podcastGuid !== null) {
$podcast = (new PodcastModel())->where('guid', $podcastGuid)
$podcast = new PodcastModel()
->where('guid', $podcastGuid)
->first();
} else {
$podcast = (new PodcastModel())->where('handle', $this->importTask->handle)
$podcast = new PodcastModel()
->where('handle', $this->importTask->handle)
->first();
}
@ -178,7 +187,7 @@ class PodcastImport extends BaseCommand
private function getOldestEpisodePublicationDate(int $podcastId): ?Time
{
$result = (new EpisodeModel())
$result = new EpisodeModel()
->builder()
->selectMax('published_at', 'oldest_published_at')
->where('podcast_id', $podcastId)
@ -514,7 +523,7 @@ class PodcastImport extends BaseCommand
*/
private function getImportedGUIDs(int $podcastId): array
{
$result = (new EpisodeModel())
$result = new EpisodeModel()
->builder()
->select('guid')
->where('podcast_id', $podcastId)

View file

@ -36,7 +36,7 @@ class PodcastImportController extends BaseController
public function podcastList(int $podcastId): string
{
if (! ($podcast = (new PodcastModel())->getPodcastById($podcastId)) instanceof Podcast) {
if (! ($podcast = new PodcastModel()->getPodcastById($podcastId)) instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
}
@ -56,8 +56,10 @@ class PodcastImportController extends BaseController
{
helper(['form', 'misc']);
$languageOptions = (new LanguageModel())->getLanguageOptions();
$categoryOptions = (new CategoryModel())->getCategoryOptions();
$languageOptions = new LanguageModel()
->getLanguageOptions();
$categoryOptions = new CategoryModel()
->getCategoryOptions();
$data = [
'languageOptions' => $languageOptions,
@ -109,7 +111,7 @@ class PodcastImportController extends BaseController
public function syncImport(int $podcastId): string
{
if (! ($podcast = (new PodcastModel())->getPodcastById($podcastId)) instanceof Podcast) {
if (! ($podcast = new PodcastModel()->getPodcastById($podcastId)) instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
}
@ -126,7 +128,7 @@ class PodcastImportController extends BaseController
public function syncImportAttempt(int $podcastId): RedirectResponse
{
if (! ($podcast = (new PodcastModel())->getPodcastById($podcastId)) instanceof Podcast) {
if (! ($podcast = new PodcastModel()->getPodcastById($podcastId)) instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
}

View file

@ -24,7 +24,7 @@ if (! function_exists('get_import_tasks')) {
if ($podcastHandle !== null) {
$podcastImportsQueue = array_filter(
$podcastImportsQueue,
static fn ($importTask): bool => $importTask->handle === $podcastHandle,
static fn (PodcastImportTask $importTask): bool => $importTask->handle === $podcastHandle,
);
}

View file

@ -34,7 +34,7 @@ class LockController extends BaseController
throw PageNotFoundException::forPageNotFound();
}
if (! ($podcast = (new PodcastModel())->getPodcastByHandle($params[0])) instanceof Podcast) {
if (! ($podcast = new PodcastModel()->getPodcastByHandle($params[0])) instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
}

View file

@ -32,7 +32,7 @@ class SubscriptionController extends BaseController
throw PageNotFoundException::forPageNotFound();
}
if (! ($podcast = (new PodcastModel())->getPodcastById((int) $params[0])) instanceof Podcast) {
if (! ($podcast = new PodcastModel()->getPodcastById((int) $params[0])) instanceof Podcast) {
throw PageNotFoundException::forPageNotFound();
}
@ -42,7 +42,7 @@ class SubscriptionController extends BaseController
return $this->{$method}();
}
if (! ($this->subscription = (new SubscriptionModel())->getSubscriptionById(
if (! ($this->subscription = new SubscriptionModel()->getSubscriptionById(
(int) $params[1],
)) instanceof Subscription) {
throw PageNotFoundException::forPageNotFound();
@ -431,7 +431,8 @@ class SubscriptionController extends BaseController
$db = db_connect();
$db->transStart();
(new SubscriptionModel())->delete($this->subscription->id);
new SubscriptionModel()
->delete($this->subscription->id);
/** @var Email $email */
$email = service('email');

View file

@ -105,7 +105,8 @@ class Subscription extends Entity
}
if (! $this->podcast instanceof Podcast) {
$this->podcast = (new PodcastModel())->getPodcastById($this->podcast_id);
$this->podcast = new PodcastModel()
->getPodcastById($this->podcast_id);
}
return $this->podcast;
@ -113,9 +114,7 @@ class Subscription extends Entity
public function getDownloadsLast3Months(): int
{
return (new AnalyticsPodcastBySubscriptionModel())->getNumberOfDownloadsLast3Months(
$this->podcast_id,
$this->id,
);
return new AnalyticsPodcastBySubscriptionModel()
->getNumberOfDownloadsLast3Months($this->podcast_id, $this->id);
}
}

View file

@ -52,7 +52,8 @@ class PodcastUnlockFilter implements FilterInterface
return null;
}
$episode = (new EpisodeModel())->getEpisodeBySlug($routerParams[0], $routerParams[1]);
$episode = new EpisodeModel()
->getEpisodeBySlug($routerParams[0], $routerParams[1]);
if (! $episode instanceof Episode) {
return null;

View file

@ -134,7 +134,8 @@ class SubscriptionModel extends Model
protected function clearCache(array $data): array
{
/** @var ?Subscription */
$subscription = (new self())->find(is_array($data['id']) ? $data['id'][0] : $data['id']);
$subscription = new self()
->find(is_array($data['id']) ? $data['id'][0] : $data['id']);
if (! $subscription instanceof Subscription) {
return $data;

View file

@ -78,12 +78,14 @@ class Publish extends BaseCommand
}
// set podcast feed as having been pushed onto hubs
(new PodcastModel())->update($podcast->id, [
'is_published_on_hubs' => 1,
]);
new PodcastModel()
->update($podcast->id, [
'is_published_on_hubs' => 1,
]);
// set newly published episodes as pushed onto hubs
(new EpisodeModel())->set('is_published_on_hubs', true)
new EpisodeModel()
->set('is_published_on_hubs', true)
->where([
'podcast_id' => $podcast->id,
'is_published_on_hubs' => false,