Bugfix: The nickname vanished/better way to fetch the alias

This commit is contained in:
Michael Vogel 2016-04-02 15:41:55 +02:00 committed by Roland Haeder
parent 7158390b98
commit 0c6ff4202d
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
4 changed files with 23 additions and 8 deletions

View file

@ -23,6 +23,8 @@ function scrape_dfrn($url, $dont_probe = false) {
if (is_array($noscrapedata)) {
if ($noscrapedata["nick"] != "")
return($noscrapedata);
else
unset($noscrapedata["nick"]);
} else
$noscrapedata = array();
}
@ -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']))
);

View 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

View 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();

View 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),