Skip to content

Commit

Permalink
Redirects requests with invalid start values to the correct page
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
  • Loading branch information
Sesquipedalian committed Feb 13, 2025
1 parent 5d57206 commit 73fbb33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Sources/Actions/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,10 @@ protected function setPaginationAndLinks(): void
Utils::$context['start'] = (int) $_REQUEST['start'];
Utils::$context['page_index'] = new PageIndex(Config::$scripturl . '?topic=' . Topic::$info->id . '.%1$d', Utils::$context['start'], Topic::$info->total_visible_posts - 1, (int) Utils::$context['messages_per_page'], true);

// SMF has a logic issue where we don't get the proper start in our query, quick fix.
// @ TODO; Properly fix this, remove this and load a topic with ?topic=123.msg456
$_REQUEST['start'] = Utils::$context['start'];
// If the supplied start value was invalid, redirect to the correct one.
if ($_REQUEST['start'] != Utils::$context['start']) {
Utils::redirectexit('topic=' . Topic::$info->id . '.' . Utils::$context['start']);
}

// This is information about which page is current, and which page we're on - in case you don't like the constructed page index. (again, wireless..)
Utils::$context['page_info'] = [
Expand Down
6 changes: 5 additions & 1 deletion Sources/Actions/MessageIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,11 @@ protected function setPaginationAndLinks(): void
Utils::$context['page_index'] = new PageIndex(Config::$scripturl . '?board=' . Board::$info->id . '.%1$d', $start, Board::$info->total_topics - 1, (int) Utils::$context['maxindex'], true);
}

$_REQUEST['start'] = $start;
// If the supplied start value was invalid, redirect to the correct one.
if ($_REQUEST['start'] != $start) {
Utils::redirectexit('board=' . Board::$info->id . '.' . $start . ($this->sort_default == $this->sort_by ? '' : ';sort=' . $this->sort_by) . ($this->ascending_is_default ? '' : ($this->ascending ? ';asc' : ';desc')));
}

Utils::$context['start'] = &$_REQUEST['start'];

$can_show_all = !empty(Config::$modSettings['enableAllMessages']) && Utils::$context['maxindex'] > Config::$modSettings['enableAllMessages'];
Expand Down

0 comments on commit 73fbb33

Please # to comment.