]> git.mxchange.org Git - friendica.git/commitdiff
Check before doing the database update
authorMichael Vogel <icarus@dabo.de>
Thu, 28 Apr 2016 04:56:55 +0000 (06:56 +0200)
committerMichael Vogel <icarus@dabo.de>
Thu, 28 Apr 2016 04:56:55 +0000 (06:56 +0200)
include/api.php

index 996c52f54eee646d8c62adcf032fa5d829ec5f61..488e858445648baedf6eb8a0f2a7aa99b936451a 100644 (file)
 
                $idlist = implode(",", $idarray);
 
-               if ($idlist != "")
-                       $r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` AND `id` IN (%s)", $idlist);
+               if ($idlist != "") {
+                       $unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `id` IN (%s)", $idlist);
 
+                       if ($unseen)
+                               $r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` AND `id` IN (%s)", $idlist);
+               }
 
                $data = array('$statuses' => $ret);
                switch($type){