Avoid write operations if not needed

This commit is contained in:
Michael Vogel 2016-04-23 00:06:34 +02:00
commit ca2454eeb4
2 changed files with 24 additions and 10 deletions

View 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`");