From 6cf595986d8d8eebd315fb9fd8cf05930bcc11ec Mon Sep 17 00:00:00 2001 From: albertlast Date: Sun, 9 Aug 2026 19:40:10 +0200 Subject: [PATCH] Logs an error for every personal message search no longer Searching your personal messages put a row in the error log every time: 2: Undefined array key "start" /index.php?action=pm;sa=search2 Search::performSearch() reads the start twice. The first read guards itself, the second does not, and a search arrives without one - only the page links a member clicks afterwards carry it. The value is already on hand as $this->start, read once and guarded when the search was set up, so use that. PageIndex takes its start by reference and clamps it, which is the whole point of the comparison below, so it gets a copy and the original stays around to compare against. Out of range starts still redirect: start=999 and start=-5 both come back as ;start=0. A plain search adds nothing to the log now. Signed-off-by: Mathias Albert Signed-off-by: albertlast --- Sources/PersonalMessage/Search.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/PersonalMessage/Search.php b/Sources/PersonalMessage/Search.php index 993d190434..58eabf5d76 100644 --- a/Sources/PersonalMessage/Search.php +++ b/Sources/PersonalMessage/Search.php @@ -318,8 +318,11 @@ public function performSearch(): void // Load the users... User::load(Utils::$context['posters']); - // Sort out the page index. - $start = (int) ($_GET['start'] ?? 0); + // Sort out the page index. PageIndex takes this by reference and clamps + // it, so hand it a copy of what was asked for and keep the original to + // compare against. Reading $_GET again here instead is what left the + // line below unguarded, since a search arrives without a start. + $start = $this->start; Utils::$context['page_index'] = new PageIndex( Config::$scripturl . '?action=pm;sa=search2;params=' . $this->compressed_params, $start, @@ -329,7 +332,7 @@ public function performSearch(): void ); // If the supplied start value was invalid, redirect to the correct one. - if ($_GET['start'] != $start) { + if ($this->start != $start) { Utils::redirectexit(Utils::$context['page_index']->base_url . ';start=' . $start); }