From: Tobias Kappé Date: Sun, 12 Aug 2018 15:17:13 +0000 (+0100) Subject: Determine language for atom entry without a loop. X-Git-Tag: 18.8~4^2 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=a377d5c981471f86c0d0c121be799aa0868e220e;p=tt-rss.git Determine language for atom entry without a loop. --- diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index 6e7a904f..ee559175 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -1,5 +1,6 @@ elem->getElementsByTagName("id")->item(0); @@ -198,12 +199,13 @@ class FeedItem_Atom extends FeedItem_Common { } function get_language() { - $elem = $this->elem; - do { - $lang = $elem->getAttributeNS("http://www.w3.org/XML/1998/namespace", "lang"); - $elem = $elem->parentNode; - } while (empty($lang) && $elem instanceof DOMElement); + $lang = $this->elem->getAttributeNS(self::NS_XML, "lang"); - return $lang; + if (!empty($lang)) { + return $lang; + } else { + // Fall back to the language declared on the feed, if any. + return $this->doc->firstChild->getAttributeNS(self::NS_XML, "lang"); + } } }