Merge pull request 'Handle fetch issues in 'RSSUtils::update_basic_info'.' (#101) from wn/tt-rss:bugfix/handle-failed-basic-info-fetch into master

Reviewed-on: https://dev.tt-rss.org/tt-rss/tt-rss/pulls/101
This commit is contained in:
fox 2023-02-19 12:03:49 +03:00
commit fcfcb69a2e
1 changed files with 13 additions and 7 deletions

View File

@ -316,14 +316,20 @@ class RSSUtils {
$feed_data = trim($feed_data); $feed_data = trim($feed_data);
$rss = new FeedParser($feed_data); if ($feed_data) {
$rss->init(); $rss = new FeedParser($feed_data);
$rss->init();
if (!$rss->error()) { if (!$rss->error()) {
$basic_info = [ $basic_info = [
'title' => mb_substr(clean($rss->get_title()), 0, 199), 'title' => mb_substr(clean($rss->get_title()), 0, 199),
'site_url' => mb_substr(UrlHelper::rewrite_relative($feed->feed_url, clean($rss->get_link())), 0, 245), 'site_url' => mb_substr(UrlHelper::rewrite_relative($feed->feed_url, clean($rss->get_link())), 0, 245),
]; ];
} else {
Debug::log(sprintf("unable to parse feed for basic info: %s", $rss->error()), Debug::LOG_VERBOSE);
}
} else {
Debug::log(sprintf("unable to fetch feed for basic info: %s [%s]", UrlHelper::$fetch_last_error, UrlHelper::$fetch_last_error_code), Debug::LOG_VERBOSE);
} }
} }