From a377d5c981471f86c0d0c121be799aa0868e220e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Kapp=C3=A9?= Date: Sun, 12 Aug 2018 16:17:13 +0100 Subject: [PATCH] Determine language for atom entry without a loop. --- classes/feeditem/atom.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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"); + } } } -- 2.39.5