From f2adec6a7f5a7f36026dea9189a545e2466e1610 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 8 Jul 2020 09:14:34 -0400 Subject: [PATCH 1/3] Add error handling in Module\Xrd - Address part of https://github.com/friendica/friendica/issues/8475#issuecomment-653912096 --- src/Module/Xrd.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 1a7b0712f..249c143ff 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -85,6 +85,11 @@ class Xrd extends BaseModule $owner = User::getOwnerDataById($user['uid']); + if (empty($owner)) { + DI::logger()->warning('No owner data for user id', ['uri' => $uri, 'name' => $name, 'user' => $user]); + throw new \Friendica\Network\HTTPException\NotFoundException(); + } + $alias = str_replace('/profile/', '/~', $owner['url']); $avatar = Photo::selectFirst(['type'], ['uid' => $owner['uid'], 'profile' => true]); From 1f0b7690eb24781348c0baa697eae9ab0e4b92a9 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 8 Jul 2020 09:49:39 -0400 Subject: [PATCH 2/3] Add error handling in Module\Profile\Status - Address part of https://github.com/friendica/friendica/issues/8475#issuecomment-653912096 --- src/Module/Profile/Status.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index 75ba60cb2..9ab15a4e3 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -34,6 +34,7 @@ use Friendica\Model\Profile as ProfileModel; use Friendica\Model\User; use Friendica\Module\BaseProfile; use Friendica\Module\Security\Login; +use Friendica\Network\HTTPException; use Friendica\Util\DateTimeFormat; use Friendica\Util\Security; use Friendica\Util\Strings; @@ -49,6 +50,10 @@ class Status extends BaseProfile ProfileModel::load($a, $parameters['nickname']); + if (empty($a->profile)) { + throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); + } + if (!$a->profile['net-publish']) { DI::page()['htmlhead'] .= '' . "\n"; } From 68ecbcea34275993bfa215ea0e6fbfa85327326c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 8 Jul 2020 09:56:40 -0400 Subject: [PATCH 3/3] Add logging to unexpected case in Content\Nav - Address part of https://github.com/friendica/friendica/issues/8475#issuecomment-653912096 --- src/Content/Nav.php | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Content/Nav.php b/src/Content/Nav.php index c3e021857..4a9c71ce9 100644 --- a/src/Content/Nav.php +++ b/src/Content/Nav.php @@ -171,20 +171,24 @@ class Nav } if (local_user()) { - // user menu - $nav['usermenu'][] = ['profile/' . $a->user['nickname'], DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')]; - $nav['usermenu'][] = ['profile/' . $a->user['nickname'] . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')]; - $nav['usermenu'][] = ['photos/' . $a->user['nickname'], DI::l10n()->t('Photos'), '', DI::l10n()->t('Your photos')]; - $nav['usermenu'][] = ['videos/' . $a->user['nickname'], DI::l10n()->t('Videos'), '', DI::l10n()->t('Your videos')]; - $nav['usermenu'][] = ['events/', DI::l10n()->t('Events'), '', DI::l10n()->t('Your events')]; - $nav['usermenu'][] = ['notes/', DI::l10n()->t('Personal notes'), '', DI::l10n()->t('Your personal notes')]; + if (!empty($a->user)) { + // user menu + $nav['usermenu'][] = ['profile/' . $a->user['nickname'], DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')]; + $nav['usermenu'][] = ['profile/' . $a->user['nickname'] . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')]; + $nav['usermenu'][] = ['photos/' . $a->user['nickname'], DI::l10n()->t('Photos'), '', DI::l10n()->t('Your photos')]; + $nav['usermenu'][] = ['videos/' . $a->user['nickname'], DI::l10n()->t('Videos'), '', DI::l10n()->t('Your videos')]; + $nav['usermenu'][] = ['events/', DI::l10n()->t('Events'), '', DI::l10n()->t('Your events')]; + $nav['usermenu'][] = ['notes/', DI::l10n()->t('Personal notes'), '', DI::l10n()->t('Your personal notes')]; - // user info - $contact = DBA::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]); - $userinfo = [ - 'icon' => (DBA::isResult($contact) ? DI::baseUrl()->remove($contact['micro']) : 'images/person-48.jpg'), - 'name' => $a->user['username'], - ]; + // user info + $contact = DBA::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]); + $userinfo = [ + 'icon' => (DBA::isResult($contact) ? DI::baseUrl()->remove($contact['micro']) : 'images/person-48.jpg'), + 'name' => $a->user['username'], + ]; + } else { + DI::logger()->warning('Empty $a->user for local user'. ['local_user' => local_user(), '$a' => $a]); + } } // "Home" should also take you home from an authenticated remote profile connection