]> git.mxchange.org Git - friendica.git/commitdiff
Avoid write operations if not needed
authorMichael Vogel <icarus@dabo.de>
Fri, 22 Apr 2016 22:06:34 +0000 (00:06 +0200)
committerMichael Vogel <icarus@dabo.de>
Fri, 22 Apr 2016 22:06:34 +0000 (00:06 +0200)
mod/display.php
mod/network.php

index e53f9e20669d7ed70b93b579f85305494861abb0..fbbd26317281adf1a9f8c76e87bbe2c413bfa02c 100644 (file)
@@ -437,10 +437,14 @@ function display_content(&$a, $update = 0) {
        if($r) {
 
                if((local_user()) && (local_user() == $a->profile['uid'])) {
-                       q("UPDATE `item` SET `unseen` = 0
-                               WHERE `parent` = %d AND `unseen`",
-                               intval($r[0]['parent'])
-                       );
+                       $unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `parent` = %d",
+                                       intval($r[0]['parent']));
+
+                       if ($unseen)
+                               q("UPDATE `item` SET `unseen` = 0
+                                       WHERE `parent` = %d AND `unseen`",
+                                       intval($r[0]['parent'])
+                               );
                }
 
                $items = conv_sort($r,"`commented`");
index a9f369a894182fac5831c85d63438b3b04baa121..95efc362607d05ab57bddf86a7fca7b10ff895c8 100644 (file)
@@ -857,14 +857,24 @@ function network_content(&$a, $update = 0) {
 
 
        if((! $group) && (! $cid) && (! $star)) {
-               $r = q("UPDATE `item` SET `unseen` = 0
-                       WHERE `unseen` = 1 AND `uid` = %d",
-                       intval(local_user())
-               );
+
+               $unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `uid` = %d",
+                               intval(local_user()));
+
+               if ($unseen)
+                       $r = q("UPDATE `item` SET `unseen` = 0
+                               WHERE `unseen` = 1 AND `uid` = %d",
+                               intval(local_user())
+                       );
        }
        else {
-               if($update_unseen)
-                       $r = q("UPDATE `item` SET `unseen` = 0 $update_unseen");
+               if($update_unseen) {
+
+                       $unseen = q("SELECT `id` FROM `item` ".$update_unseen);
+
+                       if ($unseen)
+                               $r = q("UPDATE `item` SET `unseen` = 0 $update_unseen");
+               }
        }
 
        // Set this so that the conversation function can find out contact info for our wall-wall items