Merge pull request #5280 from annando/issue-5276

Fixes Issue 5276 and an endless loop in item::update
2022.09-rc
Tobias Diekershoff 2018-06-23 12:44:43 +02:00 zatwierdzone przez GitHub
commit 62a61a95d3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 16 dodań i 51 usunięć

Wyświetl plik

@ -1343,42 +1343,14 @@ function photos_content(App $a)
if (DBM::is_result($linked_items)) { if (DBM::is_result($linked_items)) {
// This is a workaround to not being forced to rewrite the while $sql_extra handling // This is a workaround to not being forced to rewrite the while $sql_extra handling
$link_item = Item::selectFirstForUser(local_user(), [], ['id' => $linked_items[0]['id']]); $link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]);
$r = q("SELECT COUNT(*) AS `total` $condition = ["`parent` = ? AND `parent` != `id`", $link_item['parent']];
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` $a->set_pager_total(dba::count('item', $condition));
WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`uid` = %d
$sql_extra ",
dbesc($link_item['uri']),
dbesc($link_item['uri']),
intval($link_item['uid'])
); $params = ['order' => ['id'], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
$result = Item::selectForUser($link_item['uid'], [], $condition, $params);
if (DBM::is_result($r)) { $items = Item::inArray($result);
$a->set_pager_total($r[0]['total']);
}
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`,
`contact`.`rel`, `contact`.`thumb`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`uid` = %d
$sql_extra
ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
dbesc($link_item['uri']),
dbesc($link_item['uri']),
intval($link_item['uid']),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
if (local_user() && (local_user() == $link_item['uid'])) { if (local_user() && (local_user() == $link_item['uid'])) {
Item::update(['unseen' => false], ['parent' => $link_item['parent']]); Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
@ -1465,7 +1437,7 @@ function photos_content(App $a)
]); ]);
} }
if (!DBM::is_result($r)) { if (!DBM::is_result($items)) {
if (($can_post || can_write_wall($owner_uid))) { if (($can_post || can_write_wall($owner_uid))) {
$comments .= replace_macros($cmnt_tpl, [ $comments .= replace_macros($cmnt_tpl, [
'$return_path' => '', '$return_path' => '',
@ -1493,8 +1465,8 @@ function photos_content(App $a)
]; ];
// display comments // display comments
if (DBM::is_result($r)) { if (DBM::is_result($items)) {
foreach ($r as $item) { foreach ($items as $item) {
builtin_activity_puller($item, $conv_responses); builtin_activity_puller($item, $conv_responses);
} }
@ -1525,7 +1497,7 @@ function photos_content(App $a)
]); ]);
} }
foreach ($r as $item) { foreach ($items as $item) {
$comment = ''; $comment = '';
$template = $tpl; $template = $tpl;
$sparkle = ''; $sparkle = '';
@ -1534,20 +1506,13 @@ function photos_content(App $a)
continue; continue;
} }
$profile_url = Contact::MagicLinkById($item['cid']); $profile_url = Contact::MagicLinkById($item['author-id']);
if (strpos($profile_url, 'redir/') === 0) { if (strpos($profile_url, 'redir/') === 0) {
$sparkle = ' sparkle'; $sparkle = ' sparkle';
} else { } else {
$sparkle = ''; $sparkle = '';
} }
$diff_author = (($item['url'] !== $item['author-link']) ? true : false);
$profile_name = ((strlen($item['author-name']) && $diff_author) ? $item['author-name'] : $item['name']);
$profile_avatar = ((strlen($item['author-avatar']) && $diff_author) ? $item['author-avatar'] : $item['thumb']);
$profile_link = $profile_url;
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user())); $dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user()));
$drop = [ $drop = [
'dropping' => $dropping, 'dropping' => $dropping,
@ -1556,15 +1521,14 @@ function photos_content(App $a)
'delete' => L10n::t('Delete'), 'delete' => L10n::t('Delete'),
]; ];
$name_e = $profile_name;
$title_e = $item['title']; $title_e = $item['title'];
$body_e = BBCode::convert($item['body']); $body_e = BBCode::convert($item['body']);
$comments .= replace_macros($template,[ $comments .= replace_macros($template,[
'$id' => $item['item_id'], '$id' => $item['item_id'],
'$profile_url' => $profile_link, '$profile_url' => $profile_url,
'$name' => $name_e, '$name' => $item['author-name'],
'$thumb' => $profile_avatar, '$thumb' => $item['author-avatar'],
'$sparkle' => $sparkle, '$sparkle' => $sparkle,
'$title' => $title_e, '$title' => $title_e,
'$body' => $body_e, '$body' => $body_e,

Wyświetl plik

@ -115,7 +115,8 @@ class Term
$users = q("SELECT `uid` FROM `contact` WHERE self AND (`url` = '%s' OR `nurl` = '%s')", $link, $link); $users = q("SELECT `uid` FROM `contact` WHERE self AND (`url` = '%s' OR `nurl` = '%s')", $link, $link);
foreach ($users AS $user) { foreach ($users AS $user) {
if ($user['uid'] == $message['uid']) { if ($user['uid'] == $message['uid']) {
Item::update(['mention' => true], ['id' => $itemid]); /// @todo This function is called frim Item::update - so we mustn't call that function here
dba::update('item', ['mention' => true], ['id' => $itemid]);
dba::update('thread', ['mention' => true], ['iid' => $message['parent']]); dba::update('thread', ['mention' => true], ['iid' => $message['parent']]);
} }
} }