Skip to content
Snippets Groups Projects
Commit 687b5e9a authored by Daniel Siepmann's avatar Daniel Siepmann Committed by Georg Ringer
Browse files

[BUGFIX] Show latest rss entries first in rss widget

Sort rss entries before reducing to shown limit.

Resolves: #90770
Releases: master
Change-Id: Ia95d36a06408d115fb92786c361c21227f06c792
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63756


Tested-by: default avatarRichard Haeser <richard@maxserv.com>
Tested-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: default avatarRichard Haeser <richard@maxserv.com>
Reviewed-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
parent c23a764b
Branches
Tags
No related merge requests found
...@@ -108,21 +108,20 @@ class RssWidget implements WidgetInterface ...@@ -108,21 +108,20 @@ class RssWidget implements WidgetInterface
throw new \RuntimeException('RSS URL could not be fetched', 1573385431); throw new \RuntimeException('RSS URL could not be fetched', 1573385431);
} }
$rssFeed = simplexml_load_string($rssContent); $rssFeed = simplexml_load_string($rssContent);
$itemCount = 0;
$items = []; $items = [];
foreach ($rssFeed->channel->item as $item) { foreach ($rssFeed->channel->item as $item) {
if ($itemCount >= $this->options['limit']) {
break;
}
$items[] = [ $items[] = [
'title' => (string)$item->title, 'title' => trim((string)$item->title),
'link' => trim((string)$item->link), 'link' => trim((string)$item->link),
'pubDate' => (string)$item->pubDate, 'pubDate' => trim((string)$item->pubDate),
'description' => (string)$item->description, 'description' => trim((string)$item->description),
]; ];
$itemCount++;
} }
usort($items, function ($item1, $item2) {
return new \DateTime($item2['pubDate']) <=> new \DateTime($item1['pubDate']);
});
$items = array_slice($items, 0, $this->options['limit']);
$this->cache->set($cacheHash, $items, ['dashboard_rss'], $this->options['lifeTime']); $this->cache->set($cacheHash, $items, ['dashboard_rss'], $this->options['lifeTime']);
return $items; return $items;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment