From: Michael Vogel Date: Sat, 2 Apr 2016 13:41:55 +0000 (+0200) Subject: Bugfix: The nickname vanished/better way to fetch the alias X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b4b62493e6f43ed85d9c9cecabf118814db8d454;p=friendica.git Bugfix: The nickname vanished/better way to fetch the alias --- diff --git a/include/Scrape.php b/include/Scrape.php index 9913f360d6..ac95c0d5d3 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -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'])) ); diff --git a/include/cron.php b/include/cron.php index a2482ff300..e2f4102804 100644 --- a/include/cron.php +++ b/include/cron.php @@ -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 diff --git a/include/feed.php b/include/feed.php index 04cfba75a6..293de3cc96 100644 --- a/include/feed.php +++ b/include/feed.php @@ -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(); diff --git a/mod/noscrape.php b/mod/noscrape.php index 1f7105b769..4be1a740cd 100644 --- a/mod/noscrape.php +++ b/mod/noscrape.php @@ -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),