[4.4] Feed: Fixing link selection of AtomParser (#42706)

* Feed: Fixing link selection of AtomParser

* Update libraries/src/Feed/Parser/AtomParser.php

Co-authored-by: Allon Moritz <allon.moritz@digital-peak.com>

---------
This commit is contained in:
Hannes Papenberg 2024-03-04 17:01:39 +01:00 committed by GitHub
parent 5d0163235d
commit 0a912a8d4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -223,7 +223,7 @@ class AtomParser extends FeedParser
if (filter_var($entry->uri, FILTER_VALIDATE_URL) === false && !\is_null($el->link) && $el->link) {
$link = $el->link;
if (\is_array($link)) {
if ($link->count()) {
$link = $this->bestLinkForUri($link);
}
@ -238,13 +238,13 @@ class AtomParser extends FeedParser
/**
* If there is more than one <link> in the feed entry, find the most appropriate one and return it.
*
* @param array $links Array of <link> elements from the feed entry.
* @param \SimpleXMLElement $links XML node with links from the feed entry.
*
* @return \SimpleXMLElement
*/
private function bestLinkForUri(array $links)
private function bestLinkForUri(\SimpleXMLElement $links)
{
$linkPrefs = ['', 'self', 'alternate'];
$linkPrefs = ['alternate', 'self', ''];
foreach ($linkPrefs as $pref) {
foreach ($links as $link) {