]> git.mxchange.org Git - friendica.git/commitdiff
Check for parent existence in mod/display
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 19 Dec 2019 12:47:35 +0000 (07:47 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Thu, 19 Dec 2019 12:47:35 +0000 (07:47 -0500)
- Addresses https://github.com/friendica/friendica/issues/7677#issuecomment-566079001

mod/display.php

index ba339b918519cea5018db041f628e0934fecb56a..b388b915e17a9b79c359ee6a957fe605c9769baf 100644 (file)
@@ -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']]);