]> git.mxchange.org Git - friendica.git/blobdiff - include/items.php
Merge remote-tracking branch 'upstream/develop' into 1610-performance-nodeinfo
[friendica.git] / include / items.php
index f5e568306e4765c8a5a467a5ee5d8c7859f68d2b..0871d0bf817bb5c48a7fff346c7f84901fc4901b 100644 (file)
@@ -370,6 +370,13 @@ function uri_to_guid($uri) {
 
 function item_store($arr,$force_parent = false, $notify = false, $dontcache = false) {
 
+        $perfdb   = $a->performance["database"];
+        $perfdbw  = $a->performance["database_write"];
+        $perfnet  = $a->performance["network"];
+        $perffile = $a->performance["file"];
+
+       logger("Performance: Start", LOGGER_DEBUG);
+
        // If it is a posting where users should get notifications, then define it as wall posting
        if ($notify) {
                $arr['wall'] = 1;
@@ -914,10 +921,18 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
                add_shadow_entry($arr);
        }
 
+        $perfdb   = $a->performance["database"] - $perfdb;
+        $perfdbw  = $a->performance["database_write"] - $perfdbw;
+        $perfnet  = $a->performance["network"] - $perfnet;
+        $perffile = $a->performance["file"] - $perffile;
+
+        logger("Performance: DB-R: ".round($perfdb - $perfdbw, 2)." - DB-W: ".round($perfdbw, 2)." - Net: ".round($perfnet, 2)." - File: ".round($perffile, 2), LOGGER_DEBUG);
+        //logger("Performance: DB-R: ".round($perfdb - $perfdbw, 2)." - DB-W: ".round($perfdbw, 2)." - Net: ".round($perfnet, 2), LOGGER_DEBUG);
+
        check_item_notification($current_post, $uid);
 
        if ($notify)
-               proc_run('php', "include/notifier.php", $notify_type, $current_post);
+               proc_run(PRIORITY_HIGH, "include/notifier.php", $notify_type, $current_post);
 
        return $current_post;
 }
@@ -1156,7 +1171,7 @@ function tag_deliver($uid,$item_id) {
        );
        update_thread($item_id);
 
-       proc_run('php','include/notifier.php','tgroup',$item_id);
+       proc_run(PRIORITY_HIGH,'include/notifier.php', 'tgroup', $item_id);
 
 }
 
@@ -1404,16 +1419,8 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
                                dbesc($url)
                );
                if(count($r)) {
-                               $contact_record = $r[0];
-
-                               $photos = import_profile_photo($photo,$importer["uid"],$contact_record["id"]);
-
-                               q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
-                                       dbesc($photos[0]),
-                                       dbesc($photos[1]),
-                                       dbesc($photos[2]),
-                                       intval($contact_record["id"])
-                               );
+                       $contact_record = $r[0];
+                       update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true);
                }
 
 
@@ -1720,7 +1727,7 @@ function item_expire($uid, $days, $network = "", $force = false) {
        } else
                $range = "AND `created` < UTC_TIMESTAMP() - INTERVAL %d DAY ";
 
-       $r = q("SELECT * FROM `item`
+       $r = q("SELECT `file`, `resource-id`, `starred`, `type`, `id` FROM `item`
                WHERE `uid` = %d $range
                AND `id` = `parent`
                $sql_extra
@@ -1771,7 +1778,7 @@ function item_expire($uid, $days, $network = "", $force = false) {
                drop_item($item['id'],false);
        }
 
-       proc_run('php',"include/notifier.php","expire","$uid");
+       proc_run(PRIORITY_HIGH,"include/notifier.php", "expire", $uid);
 
 }
 
@@ -1793,7 +1800,7 @@ function drop_items($items) {
        // multiple threads may have been deleted, send an expire notification
 
        if($uid)
-               proc_run('php',"include/notifier.php","expire","$uid");
+               proc_run(PRIORITY_HIGH,"include/notifier.php", "expire", $uid);
 }
 
 
@@ -2006,7 +2013,7 @@ function drop_item($id,$interactive = true) {
 
                // send the notification upstream/downstream as the case may be
 
-               proc_run('php',"include/notifier.php","drop","$drop_id");
+               proc_run(PRIORITY_HIGH,"include/notifier.php", "drop", $drop_id);
 
                if(! $interactive)
                        return $owner;