]> git.mxchange.org Git - friendica.git/commitdiff
Bugfix: The nickname vanished/better way to fetch the alias
authorMichael Vogel <icarus@dabo.de>
Sat, 2 Apr 2016 13:41:55 +0000 (15:41 +0200)
committerMichael Vogel <icarus@dabo.de>
Sat, 2 Apr 2016 13:41:55 +0000 (15:41 +0200)
include/Scrape.php
include/cron.php
include/feed.php
mod/noscrape.php

index 9913f360d6346ba35558fc6a90114f135c4cf0fa..ac95c0d5d3629b58c0a9e6e453850ac5405fef1e 100644 (file)
@@ -23,13 +23,15 @@ function scrape_dfrn($url, $dont_probe = false) {
                if (is_array($noscrapedata)) {
                        if ($noscrapedata["nick"] != "")
                                return($noscrapedata);
+                       else
+                               unset($noscrapedata["nick"]);
                } else
                        $noscrapedata = array();
        }
 
        $s = fetch_url($url);
 
-       if(! $s)
+       if (!$s)
                return $ret;
 
        if (!$dont_probe) {
@@ -703,6 +705,9 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
                                        if (($vcard["nick"] == "") AND ($data["header"]["author-nick"] != ""))
                                                $vcard["nick"] = $data["header"]["author-nick"];
 
+                                       if (($network == NETWORK_OSTATUS) AND ($data["header"]["author-id"] != ""))
+                                               $alias = $data["header"]["author-id"];
+
                                        if(!$profile AND ($data["header"]["author-link"] != "") AND !in_array($network, array("", NETWORK_FEED)))
                                                $profile = $data["header"]["author-link"];
                                }
@@ -844,13 +849,17 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
                /// The biggest problem is the avatar picture that could have a reduced image size.
                /// It should only be updated if the existing picture isn't existing anymore.
                if (($result['network'] != NETWORK_FEED) AND ($mode == PROBE_NORMAL) AND
-                       $result["addr"] AND $result["name"] AND $result["nick"])
-                       q("UPDATE `contact` SET `addr` = '%s', `alias` = '%s', `name` = '%s', `nick` = '%s',
-                               `success_update` = '%s' WHERE `nurl` = '%s' AND NOT `self` AND `uid` = 0",
-                               dbesc($result["addr"]),
-                               dbesc($result["alias"]),
+                       $result["name"] AND $result["nick"] AND $result["url"] AND $result["addr"] AND $result["poll"])
+                       q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `addr` = '%s',
+                                       `notify` = '%s', `poll` = '%s', `alias` = '%s', `success_update` = '%s'
+                               WHERE `nurl` = '%s' AND NOT `self` AND `uid` = 0",
                                dbesc($result["name"]),
                                dbesc($result["nick"]),
+                               dbesc($result["url"]),
+                               dbesc($result["addr"]),
+                               dbesc($result["notify"]),
+                               dbesc($result["poll"]),
+                               dbesc($result["alias"]),
                                dbesc(datetime_convert()),
                                dbesc(normalise_link($result['url']))
                );
index a2482ff300d56c4b9e07f16a504e621e221ad08b..e2f41028044d970b3463e46502db47975c43552a 100644 (file)
@@ -405,6 +405,9 @@ function cron_repair_database() {
        // This call is very "cheap" so we can do it at any time without a problem
        q("UPDATE `item` INNER JOIN `item` AS `parent` ON `parent`.`uri` = `item`.`parent-uri` AND `parent`.`uid` = `item`.`uid` SET `item`.`parent` = `parent`.`id` WHERE `item`.`parent` = 0");
 
+       // There was an issue where the nick vanishes from the contact table
+       q("UPDATE `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` SET `nick` = `nickname` WHERE `self` AND `nick`=''");
+
        /// @todo
        /// - remove thread entries without item
        /// - remove sign entries without item
index 04cfba75a69fc407cf610725e26a70a832d843a2..293de3cc965ed6b892599db7edd17c5aad6e12d4 100644 (file)
@@ -54,8 +54,10 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
                                if ($attributes->name == "href")
                                        $author["author-link"] = $attributes->textContent;
 
+               $author["author-id"] = $xpath->evaluate('/atom:feed/atom:author/atom:uri/text()')->item(0)->nodeValue;
+
                if ($author["author-link"] == "")
-                       $author["author-link"] = $xpath->evaluate('/atom:feed/atom:author/atom:uri/text()')->item(0)->nodeValue;
+                       $author["author-link"] = $author["author-id"];
 
                if ($author["author-link"] == "") {
                        $self = $xpath->query("atom:link[@rel='self']")->item(0)->attributes;
@@ -127,6 +129,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
 
                // This is no field in the item table. So we have to unset it.
                unset($author["author-nick"]);
+               unset($author["author-id"]);
        }
 
        $header = array();
index 1f7105b7690f7d1414f76345726f2dea02211729..4be1a740cd87b6eaaa4d135c256ad6b11d77bb80 100644 (file)
@@ -28,7 +28,7 @@ function noscrape_init(&$a) {
        $json_info = array(
                'fn' => $a->profile['name'],
                'addr' => $a->profile['addr'],
-               'nick' => $a->user['nickname'],
+               'nick' => $which,
                'key' => $a->profile['pubkey'],
                'homepage' => $a->get_baseurl()."/profile/{$which}",
                'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),