Merge pull request #10764 from MrPetovan/bug/notices
Return early when parent-related record isn't found
This commit is contained in:
commit
92114dbe33
3 changed files with 40 additions and 34 deletions
|
@ -74,9 +74,7 @@ class Mail
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($msg['reply']) {
|
if ($msg['reply'] && DBA::isResult($reply = DBA::selectFirst('mail', ['uri', 'uri-id'], ['parent-uri' => $msg['parent-uri'], 'reply' => false]))) {
|
||||||
$reply = DBA::selectFirst('mail', ['uri', 'uri-id'], ['parent-uri' => $msg['parent-uri'], 'reply' => false]);
|
|
||||||
|
|
||||||
$msg['thr-parent'] = $reply['uri'];
|
$msg['thr-parent'] = $reply['uri'];
|
||||||
$msg['thr-parent-id'] = $reply['uri-id'];
|
$msg['thr-parent-id'] = $reply['uri-id'];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1146,27 +1146,31 @@ class Feed
|
||||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||||
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
|
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
|
||||||
|
|
||||||
$thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]);
|
$thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner['uid'], 'uri' => $item['thr-parent']]);
|
||||||
|
|
||||||
if (DBA::isResult($thrparent)) {
|
if (DBA::isResult($thrparent)) {
|
||||||
$mentioned[$thrparent["author-link"]] = $thrparent["author-link"];
|
$mentioned[$thrparent['author-link']] = $thrparent['author-link'];
|
||||||
$mentioned[$thrparent["owner-link"]] = $thrparent["owner-link"];
|
$mentioned[$thrparent['owner-link']] = $thrparent['owner-link'];
|
||||||
$parent_plink = $thrparent["plink"];
|
$parent_plink = $thrparent['plink'];
|
||||||
|
} elseif (DBA::isResult($parent)) {
|
||||||
|
$mentioned[$parent['author-link']] = $parent['author-link'];
|
||||||
|
$mentioned[$parent['owner-link']] = $parent['owner-link'];
|
||||||
|
$parent_plink = DI::baseUrl() . '/display/' . $parent['guid'];
|
||||||
} else {
|
} else {
|
||||||
$mentioned[$parent["author-link"]] = $parent["author-link"];
|
DI::logger()->notice('Missing parent and thr-parent for child item', ['item' => $item]);
|
||||||
$mentioned[$parent["owner-link"]] = $parent["owner-link"];
|
|
||||||
$parent_plink = DI::baseUrl()."/display/".$parent["guid"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($parent_plink)) {
|
||||||
$attributes = [
|
$attributes = [
|
||||||
"ref" => $item['thr-parent'],
|
'ref' => $item['thr-parent'],
|
||||||
"href" => $parent_plink];
|
'href' => $parent_plink];
|
||||||
XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
|
XML::addElement($doc, $entry, 'thr:in-reply-to', '', $attributes);
|
||||||
|
|
||||||
$attributes = [
|
$attributes = [
|
||||||
"rel" => "related",
|
'rel' => 'related',
|
||||||
"href" => $parent_plink];
|
'href' => $parent_plink];
|
||||||
XML::addElement($doc, $entry, "link", "", $attributes);
|
XML::addElement($doc, $entry, 'link', '', $attributes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// uri-id isn't present for follow entry pseudo-items
|
// uri-id isn't present for follow entry pseudo-items
|
||||||
|
@ -1177,7 +1181,7 @@ class Feed
|
||||||
|
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if ($tag['type'] == Tag::HASHTAG) {
|
if ($tag['type'] == Tag::HASHTAG) {
|
||||||
XML::addElement($doc, $entry, "category", "", ["term" => $tag['name']]);
|
XML::addElement($doc, $entry, 'category', '', ['term' => $tag['name']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1931,27 +1931,31 @@ class OStatus
|
||||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||||
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
|
$parent = Post::selectFirst(['guid', 'author-link', 'owner-link'], ['id' => $item['parent']]);
|
||||||
|
|
||||||
$thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner["uid"], 'uri' => $item['thr-parent']]);
|
$thrparent = Post::selectFirst(['guid', 'author-link', 'owner-link', 'plink'], ['uid' => $owner['uid'], 'uri' => $item['thr-parent']]);
|
||||||
|
|
||||||
if (DBA::isResult($thrparent)) {
|
if (DBA::isResult($thrparent)) {
|
||||||
$mentioned[$thrparent["author-link"]] = $thrparent["author-link"];
|
$mentioned[$thrparent['author-link']] = $thrparent['author-link'];
|
||||||
$mentioned[$thrparent["owner-link"]] = $thrparent["owner-link"];
|
$mentioned[$thrparent['owner-link']] = $thrparent['owner-link'];
|
||||||
$parent_plink = $thrparent["plink"];
|
$parent_plink = $thrparent['plink'];
|
||||||
|
} elseif (DBA::isResult($parent)) {
|
||||||
|
$mentioned[$parent['author-link']] = $parent['author-link'];
|
||||||
|
$mentioned[$parent['owner-link']] = $parent['owner-link'];
|
||||||
|
$parent_plink = DI::baseUrl() . '/display/' . $parent['guid'];
|
||||||
} else {
|
} else {
|
||||||
$mentioned[$parent["author-link"]] = $parent["author-link"];
|
DI::logger()->notice('Missing parent and thr-parent for child item', ['item' => $item]);
|
||||||
$mentioned[$parent["owner-link"]] = $parent["owner-link"];
|
|
||||||
$parent_plink = DI::baseUrl()."/display/".$parent["guid"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($parent_plink)) {
|
||||||
$attributes = [
|
$attributes = [
|
||||||
"ref" => $item['thr-parent'],
|
'ref' => $item['thr-parent'],
|
||||||
"href" => $parent_plink];
|
'href' => $parent_plink];
|
||||||
XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
|
XML::addElement($doc, $entry, 'thr:in-reply-to', '', $attributes);
|
||||||
|
|
||||||
$attributes = [
|
$attributes = [
|
||||||
"rel" => "related",
|
'rel' => 'related',
|
||||||
"href" => $parent_plink];
|
'href' => $parent_plink];
|
||||||
XML::addElement($doc, $entry, "link", "", $attributes);
|
XML::addElement($doc, $entry, 'link', '', $attributes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intval($item['parent']) > 0) {
|
if (intval($item['parent']) > 0) {
|
||||||
|
|
Loading…
Reference in a new issue