From 5a835db64e24b12256e97c4f92d2a5e0284fb7a9 Mon Sep 17 00:00:00 2001 From: Stefan SL Date: Tue, 2 Mar 2021 11:52:04 +0100 Subject: [PATCH] Fix errors on fresh install --- src/Model/NewsPodcastsModel.php | 2 +- src/NewsPodcasts.php | 29 ++++++++++++++--------------- src/NewsPodcastsBackend.php | 7 ++++++- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Model/NewsPodcastsModel.php b/src/Model/NewsPodcastsModel.php index 6254fbd..96a1b89 100755 --- a/src/Model/NewsPodcastsModel.php +++ b/src/Model/NewsPodcastsModel.php @@ -41,7 +41,7 @@ class NewsPodcastsModel extends \NewsModel public static function findPublishedByPids($arrPids, $blnFeatured = null, $intLimit = 0, $intOffset = 0, array $arrAddColumns = [], array $arrOptions = []) { if (!\is_array($arrPids) || empty($arrPids)) { - return null; + return []; } $t = static::$strTable; diff --git a/src/NewsPodcasts.php b/src/NewsPodcasts.php index 2568b71..071b63c 100755 --- a/src/NewsPodcasts.php +++ b/src/NewsPodcasts.php @@ -60,20 +60,18 @@ public function generateFeed($intId): void { $objFeed = NewsPodcastsFeedModel::findByArchive($intId); - if (null === $objFeed) { - return; - } - - $objFeed->feedName = $objFeed->alias ?: 'podcast_' . $objFeed->id; - - // Delete XML file - if ('delete' === Input::get('act')) { - Files::getInstance()->delete($objFeed->feedName . '.xml'); - } // Update XML file - else { - $this->generateFiles($objFeed->row()); - $logger = System::getContainer()->get('monolog.logger.contao'); - $logger->log(LogLevel::INFO, 'Generated podcast feed "' . $objFeed->feedName . '.xml"', ['contao' => new ContaoContext(__METHOD__, TL_CRON)]); + if (null !== $objFeed) { + $objFeed->feedName = $objFeed->alias ?: 'podcast_' . $objFeed->id; + + // Delete XML file + if ('delete' === Input::get('act')) { + Files::getInstance()->delete($objFeed->feedName . '.xml'); + } // Update XML file + else { + $this->generateFiles($objFeed->row()); + $logger = System::getContainer()->get('monolog.logger.contao'); + $logger->log(LogLevel::INFO, 'Generated podcast feed "' . $objFeed->feedName . '.xml"', ['contao' => new ContaoContext(__METHOD__, TL_CRON)]); + } } } @@ -188,7 +186,8 @@ protected static function generateFiles($arrFeed): void // Add filter, if newsCategories is installed - $arrOptions = []; + $arrOptions = []; + $arrColumns = []; if(null !== $arrFeed['news_categoriesRoot'] && NewsPodcastsBackend::checkNewsCategoriesBundle()) { $db = System::getContainer()->get('database_connection'); diff --git a/src/NewsPodcastsBackend.php b/src/NewsPodcastsBackend.php index dbd1ad0..05b3772 100755 --- a/src/NewsPodcastsBackend.php +++ b/src/NewsPodcastsBackend.php @@ -262,7 +262,12 @@ public function getAllowedArchives() public function preservePodcastFeeds() { $objFeeds = NewsPodcastsFeedModel::findAll(); - while ($objFeeds->next()) { + + if (null === $objFeeds) { + return []; + } + + while ($objFeeds->next()) { $arrFeeds[] = $objFeeds->alias ?: 'news' . $objFeeds->id; }