]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/DFRN.php
Ensure that "follow" requests can be processed
[friendica.git] / src / Protocol / DFRN.php
index 897f6a8cc5ef30e0e570263c37b8f965df253f51..79fa000f176571af17655f53d52fccda7b9ce2e7 100644 (file)
@@ -77,6 +77,11 @@ class DFRN
                }
 
                foreach ($items as $item) {
+                       // These values aren't sent when sending from the queue.
+                       /// @todo Check if we can set these values from the queue or if they are needed at all.
+                       $item["entry:comment-allow"] = defaults($item, "entry:comment-allow", true);
+                       $item["entry:cid"] = defaults($item, "entry:cid", 0);
+
                        $entry = self::entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]);
                        $root->appendChild($entry);
                }
@@ -96,7 +101,6 @@ class DFRN
         * @param boolean $onlyheader  Output only the header without content? (Default is "no")
         *
         * @return string DFRN feed entries
-        * @todo Find proper type-hints
         */
        public static function feed($dfrn_id, $owner_nick, $last_update, $direction = 0, $onlyheader = false)
        {
@@ -247,7 +251,7 @@ class DFRN
 
                if (!empty($ids)) {
                        $ret = Item::select(Item::DELIVER_FIELDLIST, ['id' => $ids]);
-                       $items = dba::inArray($ret);
+                       $items = Item::inArray($ret);
                } else {
                        $items = [];
                }
@@ -331,7 +335,7 @@ class DFRN
                }
 
                $ret = Item::select(Item::DELIVER_FIELDLIST, $condition);
-               $items = dba::inArray($ret);
+               $items = Item::inArray($ret);
                if (!DBM::is_result($items)) {
                        killme();
                }
@@ -939,10 +943,10 @@ class DFRN
 
                if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
                        $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
-                       $parent = q("SELECT `guid`,`plink` FROM `item` WHERE `uri` = '%s' AND `uid` = %d", dbesc($parent_item), intval($item['uid']));
+                       $parent = Item::selectFirst(['guid', 'plink'], ['uri' => $parent_item, 'uid' => $item['uid']]);
                        $attributes = ["ref" => $parent_item, "type" => "text/html",
-                                               "href" => $parent[0]['plink'],
-                                               "dfrn:diaspora_guid" => $parent[0]['guid']];
+                                               "href" => $parent['plink'],
+                                               "dfrn:diaspora_guid" => $parent['guid']];
                        XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
                }
 
@@ -953,10 +957,10 @@ class DFRN
                if (isset($parent_item)) {
                        $conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]);
                        if (DBM::is_result($conversation)) {
-                               if ($r['conversation-uri'] != '') {
+                               if ($conversation['conversation-uri'] != '') {
                                        $conversation_uri = $conversation['conversation-uri'];
                                }
-                               if ($r['conversation-href'] != '') {
+                               if ($conversation['conversation-href'] != '') {
                                        $conversation_href = $conversation['conversation-href'];
                                }
                        }
@@ -1535,8 +1539,8 @@ class DFRN
        private static function fetchauthor($xpath, $context, $importer, $element, $onlyfetch, $xml = "")
        {
                $author = [];
-               $author["name"] = $xpath->evaluate($element."/atom:name/text()", $context)->item(0)->nodeValue;
-               $author["link"] = $xpath->evaluate($element."/atom:uri/text()", $context)->item(0)->nodeValue;
+               $author["name"] = XML::getFirstNodeValue($xpath, $element."/atom:name/text()", $context);
+               $author["link"] = XML::getFirstNodeValue($xpath, $element."/atom:uri/text()", $context);
 
                $fields = ['id', 'uid', 'url', 'network', 'avatar-date', 'avatar', 'name-date', 'uri-date', 'addr',
                        'name', 'nick', 'about', 'location', 'keywords', 'xmpp', 'bdyear', 'bd', 'hidden', 'contact-type'];
@@ -1552,6 +1556,7 @@ class DFRN
                                logger("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml, LOGGER_DEBUG);
                        }
 
+                       $author["contact-unknown"] = true;
                        $author["contact-id"] = $importer["id"];
                        $author["network"] = $importer["network"];
                        $onlyfetch = true;
@@ -1607,33 +1612,33 @@ class DFRN
                        }
 
                        // Update contact data
-                       $value = $xpath->evaluate($element . "/dfrn:handle/text()", $context)->item(0)->nodeValue;
+                       $value = XML::getFirstNodeValue($xpath, $element . "/dfrn:handle/text()", $context);
                        if ($value != "") {
                                $poco["addr"] = $value;
                        }
 
-                       $value = $xpath->evaluate($element . "/poco:displayName/text()", $context)->item(0)->nodeValue;
+                       $value = XML::getFirstNodeValue($xpath, $element . "/poco:displayName/text()", $context);
                        if ($value != "") {
                                $poco["name"] = $value;
                        }
 
-                       $value = $xpath->evaluate($element . "/poco:preferredUsername/text()", $context)->item(0)->nodeValue;
+                       $value = XML::getFirstNodeValue($xpath, $element . "/poco:preferredUsername/text()", $context);
                        if ($value != "") {
                                $poco["nick"] = $value;
                        }
 
-                       $value = $xpath->evaluate($element . "/poco:note/text()", $context)->item(0)->nodeValue;
+                       $value = XML::getFirstNodeValue($xpath, $element . "/poco:note/text()", $context);
                        if ($value != "") {
                                $poco["about"] = $value;
                        }
 
-                       $value = $xpath->evaluate($element . "/poco:address/poco:formatted/text()", $context)->item(0)->nodeValue;
+                       $value = XML::getFirstNodeValue($xpath, $element . "/poco:address/poco:formatted/text()", $context);
                        if ($value != "") {
                                $poco["location"] = $value;
                        }
 
                        /// @todo Only search for elements with "poco:type" = "xmpp"
-                       $value = $xpath->evaluate($element . "/poco:ims/poco:value/text()", $context)->item(0)->nodeValue;
+                       $value = XML::getFirstNodeValue($xpath, $element . "/poco:ims/poco:value/text()", $context);
                        if ($value != "") {
                                $poco["xmpp"] = $value;
                        }
@@ -1646,7 +1651,7 @@ class DFRN
                        /// - poco:country
 
                        // If the "hide" element is present then the profile isn't searchable.
-                       $hide = intval($xpath->evaluate($element . "/dfrn:hide/text()", $context)->item(0)->nodeValue == "true");
+                       $hide = intval(XML::getFirstNodeValue($xpath, $element . "/dfrn:hide/text()", $context) == "true");
 
                        logger("Hidden status for contact " . $contact_old["url"] . ": " . $hide, LOGGER_DEBUG);
 
@@ -1668,7 +1673,7 @@ class DFRN
                        }
 
                        // "dfrn:birthday" contains the birthday converted to UTC
-                       $birthday = $xpath->evaluate($element . "/dfrn:birthday/text()", $context)->item(0)->nodeValue;
+                       $birthday = XML::getFirstNodeValue($xpath, $element . "/poco:birthday/text()", $context);
 
                        if (strtotime($birthday) > time()) {
                                $bd_timestamp = strtotime($birthday);
@@ -1677,7 +1682,7 @@ class DFRN
                        }
 
                        // "poco:birthday" is the birthday in the format "yyyy-mm-dd"
-                       $value = $xpath->evaluate($element . "/poco:birthday/text()", $context)->item(0)->nodeValue;
+                       $value = XML::getFirstNodeValue($xpath, $element . "/poco:birthday/text()", $context);
 
                        if (!in_array($value, ["", "0000-00-00", "0001-01-01"])) {
                                $bdyear = date("Y");
@@ -1974,9 +1979,11 @@ class DFRN
                 */
                if (!DBM::is_result($r)) {
                        // database record did not get created. Quietly give up.
-                       return false;
+                       killme();
                }
 
+               $fid = $r[0]["id"];
+
                $hash = random_string();
 
                $r = q(
@@ -2057,11 +2064,7 @@ class DFRN
                );
 
                if (!DBM::is_result($r)) {
-                       /*
-                        * @TODO maybe one day:
                        logger("Query failed to execute, no result returned in " . __FUNCTION__);
-                       killme();
-                       */
                        return false;
                }
 
@@ -2083,22 +2086,13 @@ class DFRN
                        'confirm' => $relocate["confirm"], 'notify' => $relocate["notify"],
                        'poll' => $relocate["poll"], 'site-pubkey' => $relocate["sitepubkey"]];
                $condition = ["(`id` = ?) OR (`nurl` = ?)", $importer["id"], normalise_link($old["url"])];
-               dba::update('contact', $fields, $condition);
 
-               // @TODO No dba:update here?
                dba::update('contact', $fields, $condition);
 
                Contact::updateAvatar($relocate["avatar"], $importer["importer_uid"], $importer["id"], true);
 
                logger('Contacts are updated.');
 
-               // update items
-               // This is an extreme performance killer
-               Item::update(['owner-link' => $relocate["url"]], ['owner-link' => $old["url"], 'uid' => $importer["importer_uid"]]);
-               Item::update(['author-link' => $relocate["url"]], ['author-link' => $old["url"], 'uid' => $importer["importer_uid"]]);
-
-               logger('Items are updated.');
-
                /// @TODO
                /// merge with current record, current contents have priority
                /// update record, set url-updated
@@ -2166,13 +2160,8 @@ class DFRN
 
                        $is_a_remote_action = false;
 
-                       $r = q(
-                               "SELECT `item`.`parent-uri` FROM `item`
-                               WHERE `item`.`uri` = '%s'
-                               LIMIT 1",
-                               dbesc($item["parent-uri"])
-                       );
-                       if (DBM::is_result($r)) {
+                       $parent = Item::selectFirst(['parent-uri'], ['uri' => $item["parent-uri"]]);
+                       if (DBM::is_result($parent)) {
                                $r = q(
                                        "SELECT `item`.`forum_mode`, `item`.`wall` FROM `item`
                                        INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
@@ -2180,9 +2169,9 @@ class DFRN
                                        AND `item`.`uid` = %d
                                        $sql_extra
                                        LIMIT 1",
-                                       dbesc($r[0]["parent-uri"]),
-                                       dbesc($r[0]["parent-uri"]),
-                                       dbesc($r[0]["parent-uri"]),
+                                       dbesc($parent["parent-uri"]),
+                                       dbesc($parent["parent-uri"]),
+                                       dbesc($parent["parent-uri"]),
                                        intval($importer["importer_uid"])
                                );
                                if (DBM::is_result($r)) {
@@ -2320,28 +2309,18 @@ class DFRN
                        ) {
                                $is_like = true;
                                $item["type"] = "activity";
-                               $item["gravity"] = GRAVITY_LIKE;
+                               $item["gravity"] = GRAVITY_ACTIVITY;
                                // only one like or dislike per person
                                // splitted into two queries for performance issues
-                               $r = q(
-                                       "SELECT `id` FROM `item` WHERE `uid` = %d AND `author-id` = %d AND `verb` = '%s' AND `parent-uri` = '%s' AND NOT `deleted` LIMIT 1",
-                                       intval($item["uid"]),
-                                       intval($item["author-id"]),
-                                       dbesc($item["verb"]),
-                                       dbesc($item["parent-uri"])
-                               );
-                               if (DBM::is_result($r)) {
+                               $condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
+                                       'verb' => $item["verb"], 'parent-uri' => $item["parent-uri"]];
+                               if (Item::exists($condition)) {
                                        return false;
                                }
 
-                               $r = q(
-                                       "SELECT `id` FROM `item` WHERE `uid` = %d AND `author-id` = %d AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
-                                       intval($item["uid"]),
-                                       intval($item["author-id"]),
-                                       dbesc($item["verb"]),
-                                       dbesc($item["parent-uri"])
-                               );
-                               if (DBM::is_result($r)) {
+                               $condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
+                                       'verb' => $item["verb"], 'thr-parent' => $item["parent-uri"]];
+                               if (Item::exists($condition)) {
                                        return false;
                                }
                        } else {
@@ -2353,26 +2332,17 @@ class DFRN
                                $xt = XML::parseString($item["target"], false);
 
                                if ($xt->type == ACTIVITY_OBJ_NOTE) {
-                                       $r = q(
-                                               "SELECT `id`, `tag` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
-                                               dbesc($xt->id),
-                                               intval($importer["importer_uid"])
-                                       );
-
-                                       if (!DBM::is_result($r)) {
-                                               /*
-                                                * @TODO maybe one day:
+                                       $item_tag = Item::selectFirst(['id', 'tag'], ['uri' => $xt->id, 'uid' => $importer["importer_uid"]]);
+                                       if (!DBM::is_result($item_tag)) {
                                                logger("Query failed to execute, no result returned in " . __FUNCTION__);
-                                               killme();
-                                               */
                                                return false;
                                        }
 
                                        // extract tag, if not duplicate, add to parent item
                                        if ($xo->content) {
-                                               if (!stristr($r[0]["tag"], trim($xo->content))) {
-                                                       $tag = $r[0]["tag"] . (strlen($r[0]["tag"]) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]';
-                                                       Item::update(['tag' => $tag], ['id' => $r[0]["id"]]);
+                                               if (!stristr($item_tag["tag"], trim($xo->content))) {
+                                                       $tag = $item_tag["tag"] . (strlen($item_tag["tag"]) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]';
+                                                       Item::update(['tag' => $tag], ['id' => $item_tag["id"]]);
                                                }
                                        }
                                }
@@ -2446,12 +2416,11 @@ class DFRN
                $item["source"] = $xml;
 
                // Get the uri
-               $item["uri"] = $xpath->query("atom:id/text()", $entry)->item(0)->nodeValue;
+               $item["uri"] = XML::getFirstNodeValue($xpath, "atom:id/text()", $entry);
 
-               $item["edited"] = $xpath->query("atom:updated/text()", $entry)->item(0)->nodeValue;
+               $item["edited"] = XML::getFirstNodeValue($xpath, "atom:updated/text()", $entry);
 
-               $current = dba::selectFirst('item',
-                       ['id', 'uid', 'edited', 'body'],
+               $current = Item::selectFirst(['id', 'uid', 'edited', 'body'],
                        ['uri' => $item["uri"], 'uid' => $importer["importer_uid"]]
                );
                // Is there an existing item?
@@ -2463,6 +2432,8 @@ class DFRN
                // Fetch the owner
                $owner = self::fetchauthor($xpath, $entry, $importer, "dfrn:owner", true);
 
+               $owner_unknown = (isset($owner["contact-unknown"]) && $owner["contact-unknown"]);
+
                $item["owner-link"] = $owner["link"];
                $item["owner-id"] = Contact::getIdForURL($owner["link"], 0);
 
@@ -2472,11 +2443,11 @@ class DFRN
                $item["author-link"] = $author["link"];
                $item["author-id"] = Contact::getIdForURL($author["link"], 0);
 
-               $item["title"] = $xpath->query("atom:title/text()", $entry)->item(0)->nodeValue;
+               $item["title"] = XML::getFirstNodeValue($xpath, "atom:title/text()", $entry);
 
-               $item["created"] = $xpath->query("atom:published/text()", $entry)->item(0)->nodeValue;
+               $item["created"] = XML::getFirstNodeValue($xpath, "atom:published/text()", $entry);
 
-               $item["body"] = $xpath->query("dfrn:env/text()", $entry)->item(0)->nodeValue;
+               $item["body"] = XML::getFirstNodeValue($xpath, "dfrn:env/text()", $entry);
                $item["body"] = str_replace([' ',"\t","\r","\n"], ['','','',''], $item["body"]);
                // make sure nobody is trying to sneak some html tags by us
                $item["body"] = notags(base64url_decode($item["body"]));
@@ -2509,18 +2480,15 @@ class DFRN
                // We don't need the content element since "dfrn:env" is always present
                //$item["body"] = $xpath->query("atom:content/text()", $entry)->item(0)->nodeValue;
 
-               $item["location"] = $xpath->query("dfrn:location/text()", $entry)->item(0)->nodeValue;
+               $item["location"] = XML::getFirstNodeValue($xpath, "dfrn:location/text()", $entry);
 
-               $georsspoint = $xpath->query("georss:point", $entry);
-               if ($georsspoint) {
-                       $item["coord"] = $georsspoint->item(0)->nodeValue;
-               }
+               $item["coord"] = XML::getFirstNodeValue($xpath, "georss:point", $entry);
 
-               $item["private"] = $xpath->query("dfrn:private/text()", $entry)->item(0)->nodeValue;
+               $item["private"] = XML::getFirstNodeValue($xpath, "dfrn:private/text()", $entry);
 
-               $item["extid"] = $xpath->query("dfrn:extid/text()", $entry)->item(0)->nodeValue;
+               $item["extid"] = XML::getFirstNodeValue($xpath, "dfrn:extid/text()", $entry);
 
-               if ($xpath->query("dfrn:bookmark/text()", $entry)->item(0)->nodeValue == "true") {
+               if (XML::getFirstNodeValue($xpath, "dfrn:bookmark/text()", $entry) == "true") {
                        $item["bookmark"] = true;
                }
 
@@ -2533,18 +2501,18 @@ class DFRN
                        }
                }
 
-               $item["guid"] = $xpath->query("dfrn:diaspora_guid/text()", $entry)->item(0)->nodeValue;
+               $item["guid"] = XML::getFirstNodeValue($xpath, "dfrn:diaspora_guid/text()", $entry);
 
                // We store the data from "dfrn:diaspora_signature" in a different table, this is done in "Item::insert"
-               $dsprsig = unxmlify($xpath->query("dfrn:diaspora_signature/text()", $entry)->item(0)->nodeValue);
+               $dsprsig = unxmlify(XML::getFirstNodeValue($xpath, "dfrn:diaspora_signature/text()", $entry));
                if ($dsprsig != "") {
                        $item["dsprsig"] = $dsprsig;
                }
 
-               $item["verb"] = $xpath->query("activity:verb/text()", $entry)->item(0)->nodeValue;
+               $item["verb"] = XML::getFirstNodeValue($xpath, "activity:verb/text()", $entry);
 
-               if ($xpath->query("activity:object-type/text()", $entry)->item(0)->nodeValue != "") {
-                       $item["object-type"] = $xpath->query("activity:object-type/text()", $entry)->item(0)->nodeValue;
+               if (XML::getFirstNodeValue($xpath, "activity:object-type/text()", $entry) != "") {
+                       $item["object-type"] = XML::getFirstNodeValue($xpath, "activity:object-type/text()", $entry);
                }
 
                $object = $xpath->query("activity:object", $entry)->item(0);
@@ -2581,8 +2549,10 @@ class DFRN
                                                $termhash = array_shift($parts);
                                                $termurl = implode(":", $parts);
 
-                                               if (strlen($item["tag"])) {
+                                               if (!empty($item["tag"])) {
                                                        $item["tag"] .= ",";
+                                               } else {
+                                                       $item["tag"] = "";
                                                }
 
                                                $item["tag"] .= $termhash . "[url=" . $termurl . "]" . $term . "[/url]";
@@ -2598,7 +2568,7 @@ class DFRN
                        self::parseLinks($links, $item);
                }
 
-               $item['conversation-uri'] = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue;
+               $item['conversation-uri'] = XML::getFirstNodeValue($xpath, 'ostatus:conversation/text()', $entry);
 
                $conv = $xpath->query('ostatus:conversation', $entry);
                if (is_object($conv->item(0))) {
@@ -2659,7 +2629,7 @@ class DFRN
                        }
 
                        // Is it an event?
-                       if ($item["object-type"] == ACTIVITY_OBJ_EVENT) {
+                       if (($item["object-type"] == ACTIVITY_OBJ_EVENT) && !$owner_unknown) {
                                logger("Item ".$item["uri"]." seems to contain an event.", LOGGER_DEBUG);
                                $ev = Event::fromBBCode($item["body"]);
                                if ((x($ev, "desc") || x($ev, "summary")) && x($ev, "start")) {
@@ -2692,6 +2662,13 @@ class DFRN
                        return;
                }
 
+               // This check is done here to be able to receive connection requests in "processVerbs"
+               if (($entrytype == DFRN::TOP_LEVEL) && $owner_unknown) {
+                       logger("Item won't be stored because user " . $importer["importer_uid"] . " doesn't follow " . $item["owner-link"] . ".", LOGGER_DEBUG);
+                       return;
+               }
+
+
                // Update content if 'updated' changes
                if (DBM::is_result($current)) {
                        if (self::updateContent($current, $item, $importer, $entrytype)) {
@@ -2783,13 +2760,18 @@ class DFRN
                        return false;
                }
 
-               $condition = ["`uri` = ? AND `uid` = ? AND NOT `file` LIKE '%[%'", $uri, $importer["importer_uid"]];
-               $item = dba::selectFirst('item', ['id', 'parent', 'contact-id'], $condition);
+               $condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]];
+               $item = Item::selectFirst(['id', 'parent', 'contact-id', 'file', 'deleted'], $condition);
                if (!DBM::is_result($item)) {
                        logger("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", LOGGER_DEBUG);
                        return;
                }
 
+               if (strstr($item['file'], '[')) {
+                       logger("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " is filed. So it won't be deleted.", LOGGER_DEBUG);
+                       return;
+               }
+
                // When it is a starting post it has to belong to the person that wants to delete it
                if (($item['id'] == $item['parent']) && ($item['contact-id'] != $importer["id"])) {
                        logger("Item with uri " . $uri . " don't belong to contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG);
@@ -2799,7 +2781,7 @@ class DFRN
                // Comments can be deleted by the thread owner or comment owner
                if (($item['id'] != $item['parent']) && ($item['contact-id'] != $importer["id"])) {
                        $condition = ['id' => $item['parent'], 'contact-id' => $importer["id"]];
-                       if (!dba::exists('item', $condition)) {
+                       if (!Item::exists($condition)) {
                                logger("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG);
                                return;
                        }
@@ -2867,11 +2849,11 @@ class DFRN
                logger("Import DFRN message for user " . $importer["importer_uid"] . " from contact " . $importer["id"], LOGGER_DEBUG);
 
                // is it a public forum? Private forums aren't exposed with this method
-               $forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()")->item(0)->nodeValue);
+               $forum = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:community/text()"));
 
                // The account type is new since 3.5.1
                if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) {
-                       $accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()")->item(0)->nodeValue);
+                       $accounttype = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:account_type/text()"));
 
                        if ($accounttype != $importer["contact-type"]) {
                                dba::update('contact', ['contact-type' => $accounttype], ['id' => $importer["id"]]);
@@ -2919,7 +2901,7 @@ class DFRN
                        $newentries = [];
                        $entries = $xpath->query("/atom:feed/atom:entry");
                        foreach ($entries as $entry) {
-                               $created = $xpath->query("atom:published/text()", $entry)->item(0)->nodeValue;
+                               $created = XML::getFirstNodeValue($xpath, "atom:published/text()", $entry);
                                $newentries[strtotime($created)] = $entry;
                        }