]> git.mxchange.org Git - friendica.git/blobdiff - include/text.php
Merge pull request #2744 from tobiasd/20160820-cal
[friendica.git] / include / text.php
index 13397c2ea082cffed802879f117ac1ba2d429a88..3aec42b3239b1fbee986d15b60183f53f05fc9fa 100644 (file)
@@ -717,10 +717,15 @@ function logger($msg,$level = 0) {
        if((! $debugging) || (! $logfile) || ($level > $loglevel))
                return;
 
+       $process_id = session_id();
+
+       if ($process_id == "")
+               $process_id = get_app()->process_id;
+
        $callers = debug_backtrace();
        $logline =  sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n",
                                 datetime_convert(),
-                                session_id(),
+                                $process_id,
                                 $LOGGER_LEVELS[$level],
                                 basename($callers[0]['file']),
                                 $callers[0]['line'],
@@ -867,7 +872,8 @@ function contact_block() {
                $micropro = Null;
 
        } else {
-               $r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `micro`, `network` FROM `contact`
+               // Splitting the query in two parts makes it much faster
+               $r = q("SELECT `id` FROM `contact`
                                WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending`
                                        AND NOT `hidden` AND NOT `archive`
                                AND `network` IN ('%s', '%s', '%s') ORDER BY RAND() LIMIT %d",
@@ -877,11 +883,19 @@ function contact_block() {
                                dbesc(NETWORK_DIASPORA),
                                intval($shown)
                );
-               if(count($r)) {
-                       $contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
-                       $micropro = Array();
-                       foreach($r as $rr) {
-                               $micropro[] = micropro($rr,true,'mpfriend');
+               if ($r) {
+                       $contacts = "";
+                       foreach ($r AS $contact)
+                               $contacts[] = $contact["id"];
+
+                       $r = q("SELECT `id`, `uid`, `addr`, `url`, `name`, `thumb`, `network` FROM `contact` WHERE `id` IN (%s)",
+                               dbesc(implode(",", $contacts)));
+                       if(count($r)) {
+                               $contacts = sprintf( tt('%d Contact','%d Contacts', $total),$total);
+                               $micropro = Array();
+                               foreach($r as $rr) {
+                                       $micropro[] = micropro($rr,true,'mpfriend');
+                               }
                        }
                }
        }
@@ -911,7 +925,7 @@ function contact_block() {
  *     string 'url' => The url to the profile page of the contact
  *     string 'addr' => The webbie of the contact (e.g.) username@friendica.com
  *     string 'network' => The network to which the contact belongs to
- *     string 'micro' => The contact picture
+ *     string 'thumb' => The contact picture
  *     string 'click' => js code which is performed when clicking on the contact
  * @param boolean $redirect If true try to use the redir url if it's possible
  * @param string $class CSS class for the 
@@ -950,7 +964,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
                '$click' => (($contact['click']) ? $contact['click'] : ''),
                '$class' => $class,
                '$url' => $url,
-               '$photo' => proxy_url($contact['micro'], false, PROXY_SIZE_THUMB),
+               '$photo' => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB),
                '$name' => $contact['name'],
                'title' => $contact['name'] . ' [' . $contact['addr'] . ']',
                '$parkle' => $sparkle,