From a294c19d6e5a1ebd4d34009c9321ec43b155e98a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 29 Dec 2020 21:38:23 +0000 Subject: [PATCH 1/3] Fix several notices --- mod/cal.php | 5 +++-- mod/message.php | 2 +- src/Model/Event.php | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mod/cal.php b/mod/cal.php index 1ac11dc98..2992f29e5 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -24,7 +24,6 @@ */ use Friendica\App; -use Friendica\Content\Feature; use Friendica\Content\Nav; use Friendica\Content\Text\BBCode; use Friendica\Content\Widget; @@ -69,7 +68,6 @@ function cal_init(App $a) } $a->profile = Profile::getByNickname($nick, $a->profile_uid); - if (empty($a->profile)) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); } @@ -131,6 +129,9 @@ function cal_content(App $a) // Setup permissions structures $owner_uid = intval($a->data['user']['uid']); $nick = $a->data['user']['nickname']; + if (empty($a->profile)) { + throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); + } $contact_id = Session::getRemoteContactID($a->profile['uid']); diff --git a/mod/message.php b/mod/message.php index 7a8b133f5..f12f54015 100644 --- a/mod/message.php +++ b/mod/message.php @@ -332,7 +332,7 @@ function message_content(App $a) 'id' => $message['id'], 'from_name' => $from_name_e, 'from_url' => $from_url, - 'from_addr' => $contact['addr'], + 'from_addr' => $contact['addr'] ?? $from_url, 'sparkle' => $sparkle, 'from_photo' => $from_photo, 'subject' => $subject_e, diff --git a/src/Model/Event.php b/src/Model/Event.php index 5139abc43..2b4932b4f 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -291,6 +291,9 @@ class Event } $contact = DBA::selectFirst('contact', [], $conditions); + if (!DBA::isResult($contact)) { + Logger::warning('Contact not found', ['condition' => $conditions]); + } // Existing event being modified. if ($event['id']) { From c5c9fda93cc7dd49fea056df212683c1d85b0b1a Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 30 Dec 2020 07:13:47 +0000 Subject: [PATCH 2/3] Improved logging, avoid fatal error --- mod/events.php | 3 ++- src/Model/Event.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mod/events.php b/mod/events.php index d4a902c72..bf813f683 100644 --- a/mod/events.php +++ b/mod/events.php @@ -30,6 +30,7 @@ use Friendica\Core\Theme; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Model\Contact; use Friendica\Model\Event; use Friendica\Model\Item; use Friendica\Model\User; @@ -129,7 +130,7 @@ function events_post(App $a) ]; $action = ($event_id == '') ? 'new' : 'event/' . $event_id; - $onerror_path = 'events/' . $action . '?' . http_build_query($params, null, null, PHP_QUERY_RFC3986); + $onerror_path = 'events/' . $action . '?' . http_build_query($params, '', '&', PHP_QUERY_RFC3986); if (strcmp($finish, $start) < 0 && !$nofinish) { notice(DI::l10n()->t('Event can not end before it has started.')); diff --git a/src/Model/Event.php b/src/Model/Event.php index 2b4932b4f..995941edd 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -292,7 +292,7 @@ class Event $contact = DBA::selectFirst('contact', [], $conditions); if (!DBA::isResult($contact)) { - Logger::warning('Contact not found', ['condition' => $conditions]); + Logger::warning('Contact not found', ['condition' => $conditions, 'cakkstack' => System::callstack(20)]); } // Existing event being modified. From a12380a2477f7caaf2d12c927bc95fc7186d0667 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 30 Dec 2020 09:20:46 -0500 Subject: [PATCH 3/3] Fix typo in Model\Event --- src/Model/Event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Event.php b/src/Model/Event.php index 995941edd..db99ae571 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -292,7 +292,7 @@ class Event $contact = DBA::selectFirst('contact', [], $conditions); if (!DBA::isResult($contact)) { - Logger::warning('Contact not found', ['condition' => $conditions, 'cakkstack' => System::callstack(20)]); + Logger::warning('Contact not found', ['condition' => $conditions, 'callstack' => System::callstack(20)]); } // Existing event being modified.