From bba8f03296d02225672a548f1aacfe8eac7e27d2 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 19 Dec 2019 07:47:35 -0500 Subject: [PATCH 1/2] Check for parent existence in mod/display - Addresses https://github.com/friendica/friendica/issues/7677#issuecomment-566079001 --- mod/display.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/mod/display.php b/mod/display.php index ba339b9185..b388b915e1 100644 --- a/mod/display.php +++ b/mod/display.php @@ -93,7 +93,8 @@ function display_init(App $a) } if ($item["id"] != $item["parent"]) { - $item = Item::selectFirstForUser($item_user, $fields, ['id' => $item["parent"]]); + $parent = Item::selectFirstForUser($item_user, $fields, ['id' => $item["parent"]]); + $item = $parent ?: $item; } $profiledata = display_fetchauthor($a, $item); @@ -242,16 +243,20 @@ function display_content(App $a, $update = false, $update_uid = 0) $is_remote_contact = false; $item_uid = local_user(); - if (isset($item_parent_uri)) { + $parent = null; + if (!empty($item_parent_uri)) { $parent = Item::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]); - if (DBA::isResult($parent)) { - $a->profile['uid'] = ($a->profile['uid'] ?? 0) ?: $parent['uid']; - $a->profile['profile_uid'] = ($a->profile['profile_uid'] ?? 0) ?: $parent['uid']; - $is_remote_contact = Session::getRemoteContactID($a->profile['profile_uid']); - if ($is_remote_contact) { - $item_uid = $parent['uid']; - } + } + + if (DBA::isResult($parent)) { + $a->profile['uid'] = ($a->profile['uid'] ?? 0) ?: $parent['uid']; + $a->profile['profile_uid'] = ($a->profile['profile_uid'] ?? 0) ?: $parent['uid']; + $is_remote_contact = Session::getRemoteContactID($a->profile['profile_uid']); + if ($is_remote_contact) { + $item_uid = $parent['uid']; } + } else { + $a->profile = ['uid' => intval($item['uid']), 'profile_uid' => intval($item['uid'])]; } $page_contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $a->profile['uid']]); From 33ea5dfe3567c39a78cd18e638fc746a19992c68 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 19 Dec 2019 07:48:08 -0500 Subject: [PATCH 2/2] Add check for $_REQUEST key existence in Module\Item\Compose - Addresses https://github.com/friendica/friendica/issues/7677#issuecomment-566254464 --- src/Module/Item/Compose.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index db44ee3d14..b9cda4863e 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -85,15 +85,20 @@ class Compose extends BaseModule $type = 'post'; $doesFederate = true; - if ($_REQUEST['contact_allow'] - . $_REQUEST['group_allow'] - . $_REQUEST['contact_deny'] - . $_REQUEST['group_deny']) + $contact_allow = $_REQUEST['contact_allow'] ?? ''; + $group_allow = $_REQUEST['group_allow'] ?? ''; + $contact_deny = $_REQUEST['contact_deny'] ?? ''; + $group_deny = $_REQUEST['group_deny'] ?? ''; + + if ($contact_allow + . $group_allow + . $contact_deny + . $group_deny) { - $contact_allow_list = $_REQUEST['contact_allow'] ? explode(',', $_REQUEST['contact_allow']) : []; - $group_allow_list = $_REQUEST['group_allow'] ? explode(',', $_REQUEST['group_allow']) : []; - $contact_deny_list = $_REQUEST['contact_deny'] ? explode(',', $_REQUEST['contact_deny']) : []; - $group_deny_list = $_REQUEST['group_deny'] ? explode(',', $_REQUEST['group_deny']) : []; + $contact_allow_list = $contact_allow ? explode(',', $contact_allow) : []; + $group_allow_list = $group_allow ? explode(',', $group_allow) : []; + $contact_deny_list = $contact_deny ? explode(',', $contact_deny) : []; + $group_deny_list = $group_deny ? explode(',', $group_deny) : []; } break;