From 1eb8f04274b2a731ec098be609c3938b418bde70 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 30 Jul 2018 07:06:32 +0200 Subject: [PATCH] Fixing SQL error when receiving DFRN posts (#5527) * Some more notices * Fixed nasty to find notice in DFRN and OStatus * And more notices ... * Yeah, some removed notices ... again ... * Fixing bad SQL query --- mod/dfrn_notify.php | 5 ++--- mod/hovercard.php | 26 ++++++++++++++++++++++++-- src/Protocol/Diaspora.php | 4 ++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 26985527be..d2250720a5 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -212,7 +212,8 @@ function dfrn_dispatch_public($postdata) } // We now have some contact, so we fetch it - $importer = DBA::fetchFirst("SELECT *, `name` as `senderName` + $importer = DBA::fetchFirst("SELECT *, `name` as `senderName`, + 0 AS `importer_uid`, '' AS `uprvkey`, 'UTC' AS `timezone`, '' AS `nickname`, @@ -225,8 +226,6 @@ function dfrn_dispatch_public($postdata) WHERE NOT `blocked` AND `id` = ? LIMIT 1", $contact['id']); - $importer['importer_uid'] = 0; - // This should never fail if (!DBA::isResult($importer)) { logger('Contact not found for address ' . $msg['author']); diff --git a/mod/hovercard.php b/mod/hovercard.php index 40d32be7ad..038d278c57 100644 --- a/mod/hovercard.php +++ b/mod/hovercard.php @@ -54,10 +54,32 @@ function hovercard_content() $contact = []; // if it's the url containing https it should be converted to http $nurl = normalise_link(GContact::cleanContactUrl($profileurl)); - if ($nurl) { - // Search for contact data + if (!$nurl) { + return; + } + + // Search for contact data + // Look if the local user has got the contact + if (local_user()) { + $contact = Contact::getDetailsByURL($nurl, local_user()); + } + + // If not then check the global user + if (!count($contact)) { $contact = Contact::getDetailsByURL($nurl); } + + // Feeds url could have been destroyed through "cleanContactUrl", so we now use the original url + if (!count($contact) && local_user()) { + $nurl = normalise_link($profileurl); + $contact = Contact::getDetailsByURL($nurl, local_user()); + } + + if (!count($contact)) { + $nurl = normalise_link($profileurl); + $contact = Contact::getDetailsByURL($nurl); + } + if (!count($contact)) { return; } diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 9cd6e7bc54..3a0ccd891e 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -1374,6 +1374,10 @@ class Diaspora $item = Item::selectFirst($fields, $condition); if (!DBA::isResult($item)) { + if (!isset($contact["url"])) { + logger('Missing URL: ' . System::callstack() . ' - ' . json_encode($contact)); + } + $result = self::storeByGuid($guid, $contact["url"], $uid); if (!$result) {