diff --git a/CHANGELOG.md b/CHANGELOG.md index ac167c259..4805ac454 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ You can also check [on GitHub](https://github.com/nextcloud/news/releases), the ### Fixed - fix proxy port removed if standard port for the protocol (#3027) - +- background updater may stumble over invalid datetime strings from feeds (#3028) # Releases ## [25.2.0-beta.3] - 2025-01-04 diff --git a/lib/Fetcher/FeedFetcher.php b/lib/Fetcher/FeedFetcher.php index 33bade565..9755246d3 100755 --- a/lib/Fetcher/FeedFetcher.php +++ b/lib/Fetcher/FeedFetcher.php @@ -130,7 +130,11 @@ public function fetch( $url2->setUserinfo(rawurlencode($user), rawurlencode($password)); } if (!is_null($httpLastModified) && trim($httpLastModified) !== '') { - $lastModified = new DateTime($httpLastModified); + try { + $lastModified = new DateTime($httpLastModified); + } catch (\Exception) { + $lastModified = null; + } } else { $lastModified = null; } @@ -294,11 +298,15 @@ protected function buildItem( $item->setGuidHash(md5($item->getGuid())); $lastModified = $parsedItem->getLastModified() ?? new DateTime(); - if ($parsedItem->getValue('pubDate') !== null) { - $pubDT = new DateTime($parsedItem->getValue('pubDate')); - } elseif ($parsedItem->getValue('published') !== null) { - $pubDT = new DateTime($parsedItem->getValue('published')); - } else { + try { + if ($parsedItem->getValue('pubDate') !== null) { + $pubDT = new DateTime($parsedItem->getValue('pubDate')); + } elseif ($parsedItem->getValue('published') !== null) { + $pubDT = new DateTime($parsedItem->getValue('published')); + } else { + $pubDT = $lastModified; + } + } catch (\Exception) { $pubDT = $lastModified; }