From 47478fe8f712729364c65c40ac735ccd8e8f2acb Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 15 Sep 2024 05:35:30 +0000 Subject: [PATCH] Avoid blank network page on database issues --- src/Module/Conversation/Network.php | 2 ++ src/Module/Update/Network.php | 17 +++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index e79ec5899d..49a478fbc4 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -222,7 +222,9 @@ class Network extends Timeline $o .= $this->conversation->render($items, Conversation::MODE_NETWORK, false, false, $this->getOrder(), $this->session->getLocalUserId()); } catch (\Exception $e) { + $this->logger->error('Exception when fetching items', ['code' => $e->getCode(), 'message' => $e->getMessage()]); $o .= $this->l10n->t('Error %d (%s) while fetching the timeline.', $e->getCode(), $e->getMessage()); + $items = []; } if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll')) { diff --git a/src/Module/Update/Network.php b/src/Module/Update/Network.php index 33a81eb0ee..4c04beecb4 100644 --- a/src/Module/Update/Network.php +++ b/src/Module/Update/Network.php @@ -27,12 +27,17 @@ class Network extends NetworkModule System::htmlUpdateExit($o); } - if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { - $items = $this->getChannelItems($request, $this->session->getLocalUserId()); - } elseif ($this->community->isTimeline($this->selectedTab)) { - $items = $this->getCommunityItems(); - } else { - $items = $this->getItems(); + try { + if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { + $items = $this->getChannelItems($request, $this->session->getLocalUserId()); + } elseif ($this->community->isTimeline($this->selectedTab)) { + $items = $this->getCommunityItems(); + } else { + $items = $this->getItems(); + } + } catch (\Exception $e) { + $this->logger->error('Exception when fetching items', ['code' => $e->getCode(), 'message' => $e->getMessage()]); + $items = []; } $o = $this->conversation->render($items, Conversation::MODE_NETWORK, true, false, $this->getOrder(), $this->session->getLocalUserId());