aboutsummaryrefslogtreecommitdiffstats
path: root/mod/item.php
diff options
context:
space:
mode:
authorMike Macgirvin <mike@macgirvin.com>2010-08-29 21:55:57 -0700
committerMike Macgirvin <mike@macgirvin.com>2010-08-29 21:55:57 -0700
commit2d76a5c76b173b5cc174763514127ef4de0cef62 (patch)
treedb2bc20b160c4abfc6467566fa888139bbcb037f /mod/item.php
parent5d59a77cd97725b6db4a7ade0c97ee277ed4ce73 (diff)
downloadvolse-hubzilla-2d76a5c76b173b5cc174763514127ef4de0cef62.tar.gz
volse-hubzilla-2d76a5c76b173b5cc174763514127ef4de0cef62.tar.bz2
volse-hubzilla-2d76a5c76b173b5cc174763514127ef4de0cef62.zip
fix last-child in face of deletions
Diffstat (limited to 'mod/item.php')
-rw-r--r--mod/item.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/mod/item.php b/mod/item.php
index 812216426..c790d31da 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -313,7 +313,23 @@ function item_content(&$a) {
);
// ignore the result
}
-
+ else {
+ // ensure that last-child is set in case the comment that had it just got wiped.
+ q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
+ dbesc(datetime_convert()),
+ dbesc($item['parent-uri']),
+ intval($item['uid'])
+ );
+ // who is the last child now?
+ $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 ORDER BY `edited` DESC LIMIT 1",
+ dbesc($item['parent-uri'])
+ );
+ if(count($r)) {
+ q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
+ intval($r[0]['id'])
+ );
+ }
+ }
$drop_id = intval($item['id']);
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');