]> git.mxchange.org Git - friendica.git/commitdiff
Fixing SQL error when receiving DFRN posts (#5527)
authorMichael Vogel <icarus@dabo.de>
Mon, 30 Jul 2018 05:06:32 +0000 (07:06 +0200)
committerTobias Diekershoff <tobias.diekershoff@gmx.net>
Mon, 30 Jul 2018 05:06:32 +0000 (07:06 +0200)
* 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
mod/hovercard.php
src/Protocol/Diaspora.php

index 26985527bec260fa326abd840d31ffee2e5a4863..d2250720a56a3e021543c4bc95b5b5e6f30e6724 100644 (file)
@@ -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']);
index 40d32be7ad6895462ec49cec4aba05e58db98c11..038d278c57c8990dfbb1d038cdfb6befe92026b7 100644 (file)
@@ -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;
        }
index 9cd6e7bc54bf05703dfae4179a8a5137f0ab17b0..3a0ccd891e7d95d76af8b314a525c5efe70bd2d9 100644 (file)
@@ -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) {