improved route mismatch detection. We will be less strict about the absolute route matching and only look at the last hop before it got to us - which is ultimately all we should care about (since that sender controls the thread permissions). Route mismatches seem to occur somewhat frequently from yamkote (for unknown reasons), and the logging has been improved a bit so it should provide some slightly more useful debugging info in case it still happens going forward. Oh, also we'll set the parent on comments when we store the initial post (item_store()) and only go back and set the parent for top-level posts. This should reduce the number of comments with missing parents on shared hosts, but may increase the number of missing threads. Probably worthwhile to do a query occasionally for parent = 0 and see how we're doing and how many have shared host related delivery issues.

This commit is contained in:
friendica 2015-01-27 15:47:24 -08:00
parent 525c62ab1d
commit 2f4ef7660c
2 changed files with 42 additions and 35 deletions

View File

@ -2186,6 +2186,20 @@ function item_store($arr,$allow_exec = false) {
unset($arr['term']);
}
if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid) || strlen($public_policy))
$private = 1;
else
$private = $arr['item_private'];
$arr['parent'] = $parent_id;
$arr['allow_cid'] = $allow_cid;
$arr['allow_gid'] = $allow_gid;
$arr['deny_cid'] = $deny_cid;
$arr['deny_gid'] = $deny_gid;
$arr['public_policy'] = $public_policy;
$arr['item_private'] = $private;
$arr['comments_closed'] = $comments_closed;
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
dbesc_array($arr);
@ -2203,7 +2217,6 @@ function item_store($arr,$allow_exec = false) {
intval($arr['uid'])
);
if($r && count($r)) {
$current_post = $r[0]['id'];
$arr = $r[0]; // This will gives us a fresh copy of what's now in the DB and undo the db escaping, which really messes up the notifications
@ -2223,40 +2236,14 @@ function item_store($arr,$allow_exec = false) {
);
}
if((! $parent_id) || ($arr['parent_mid'] === $arr['mid']))
$parent_id = $current_post;
$arr['id'] = $current_post;
if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid) || strlen($public_policy))
$private = 1;
else
$private = $arr['item_private'];
if(! intval($r[0]['parent'])) {
$x = q("update item set parent = id where id = %d",
intval($r[0]['id'])
);
}
// Set parent id - and also make sure to inherit the parent's ACL's.
$r = q("UPDATE item SET parent = %d, allow_cid = '%s', allow_gid = '%s',
deny_cid = '%s', deny_gid = '%s', public_policy = '%s', item_private = %d, comments_closed = '%s'
WHERE id = %d",
intval($parent_id),
dbesc($allow_cid),
dbesc($allow_gid),
dbesc($deny_cid),
dbesc($deny_gid),
dbesc($public_policy),
intval($private),
dbesc($comments_closed),
intval($current_post)
);
// These are probably redundant now that we've queried the just stored post
$arr['id'] = $current_post;
$arr['parent'] = $parent_id;
$arr['allow_cid'] = $allow_cid;
$arr['allow_gid'] = $allow_gid;
$arr['deny_cid'] = $deny_cid;
$arr['deny_gid'] = $deny_gid;
$arr['public_policy'] = $public_policy;
$arr['item_private'] = $private;
$arr['comments_closed'] = $comments_closed;
// Store taxonomy

View File

@ -1522,14 +1522,34 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque
// going downstream check that we have the same upstream provider that
// sent it to us originally. Ignore it if it came from another source
// (with potentially different permissions)
// (with potentially different permissions).
// only compare the last hop since it could have arrived at the last location any number of ways.
// Always accept empty routes.
$existing_route = explode(',', $r[0]['route']);
$routes = count($existing_route);
if($routes) {
$last_hop = array_pop($existing_route);
$last_prior_route = implode(',',$existing_route);
}
else {
$last_hop = '';
$last_prior_route = '';
}
$current_route = (($arr['route']) ? $arr['route'] . ',' : '') . $sender['hash'];
if($r[0]['route'] != $current_route) {
if($last_hop && $last_hop != $sender['hash']) {
logger('comment route mismatch: parent route = ' . $r[0]['route'] . ' expected = ' . $current_route, LOGGER_DEBUG);
logger('comment route mismatch: parent msg = ' . $r[0]['id'],LOGGER_DEBUG);
$result[] = array($d['hash'],'comment route mismatch',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
continue;
}
// we'll add sender['hash'] onto this when we deliver it. $last_prior_route now has the previously stored route
// *except* for the sender['hash'] which would've been the last hop before it got to us.
$arr['route'] = $last_prior_route;
}
}