mirror of
https://github.com/friendica/friendica
synced 2024-11-18 05:43:42 +00:00
fix last-child in face of deletions
This commit is contained in:
parent
5d59a77cd9
commit
2d76a5c76b
3 changed files with 59 additions and 5 deletions
|
@ -190,13 +190,14 @@ echo "Length:" . strlen($xml) . "\r\n";
|
||||||
intval($importer['uid'])
|
intval($importer['uid'])
|
||||||
);
|
);
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
if($r[0]['uri'] == $r[0]['parent-uri']) {
|
$item = $r[0];
|
||||||
|
if($item['uri'] == $item['parent-uri']) {
|
||||||
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
|
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
|
||||||
`body` = '', `title` = ''
|
`body` = '', `title` = ''
|
||||||
WHERE `parent-uri` = '%s'",
|
WHERE `parent-uri` = '%s'",
|
||||||
dbesc($when),
|
dbesc($when),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc($r[0]['uri'])
|
dbesc($item['uri'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -208,6 +209,24 @@ echo "Length:" . strlen($xml) . "\r\n";
|
||||||
dbesc($uri),
|
dbesc($uri),
|
||||||
intval($importer['uid'])
|
intval($importer['uid'])
|
||||||
);
|
);
|
||||||
|
if($item['last-child']) {
|
||||||
|
// 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'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -123,12 +123,13 @@ function dfrn_notify_post(&$a) {
|
||||||
intval($importer['importer_uid'])
|
intval($importer['importer_uid'])
|
||||||
);
|
);
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
if($r[0]['uri'] == $r[0]['parent-uri']) {
|
$item = $r[0];
|
||||||
|
if($item['uri'] == $item['parent-uri']) {
|
||||||
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s'
|
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s'
|
||||||
WHERE `parent-uri` = '%s'",
|
WHERE `parent-uri` = '%s'",
|
||||||
dbesc($when),
|
dbesc($when),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc($r[0]['uri'])
|
dbesc($item['uri'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -139,6 +140,24 @@ function dfrn_notify_post(&$a) {
|
||||||
dbesc($uri),
|
dbesc($uri),
|
||||||
intval($importer['importer_uid'])
|
intval($importer['importer_uid'])
|
||||||
);
|
);
|
||||||
|
if($item['last-child']) {
|
||||||
|
// 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'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
18
mod/item.php
18
mod/item.php
|
@ -313,7 +313,23 @@ function item_content(&$a) {
|
||||||
);
|
);
|
||||||
// ignore the result
|
// 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']);
|
$drop_id = intval($item['id']);
|
||||||
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue