]> git.mxchange.org Git - friendica.git/commitdiff
Switch nurl and addr lookups
authorHypolite Petovan <ben.lort@gmail.com>
Mon, 6 Mar 2017 21:26:04 +0000 (16:26 -0500)
committerHypolite Petovan <ben.lort@gmail.com>
Mon, 6 Mar 2017 21:26:04 +0000 (16:26 -0500)
- nurl lookup is more frequent than addr lookup, saves queries

include/Contact.php

index 845ee168cc77586dfa1542208f7633e3cf8107fb..1fcdc6951c1d79a85e9295bf3822194cb8b1ba1a 100644 (file)
@@ -534,19 +534,20 @@ function get_contact($url, $uid = 0, $no_update = false) {
        $data = array();
        $contact_id = 0;
 
-       // We first try the addr (nick@server.tld)
+       // We first try the nurl (http://server.tld/nick), most common case
        $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
-                               WHERE `addr` = '%s'
-                               AND `uid` = %d",
-               dbesc($url),
-               intval($uid));
+                                       WHERE `nurl` = '%s'
+                                       AND `uid` = %d",
+                       dbesc(normalise_link($url)),
+                       intval($uid));
 
-       // Then the nurl (http://server.tld/nick)
+
+       // Then the addr (nick@server.tld)
        if (! dbm::is_result($contacts)) {
                $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
-                                       WHERE `nurl` = '%s'
+                                       WHERE `addr` = '%s'
                                        AND `uid` = %d",
-                       dbesc(normalise_link($url)),
+                       dbesc($url),
                        intval($uid));
        }