Skip to content

Commit

Permalink
Show errors when ?board= and/or ?topic= are given invalid values
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <jonstovell@gmail.com>
  • Loading branch information
Sesquipedalian committed Mar 2, 2025
1 parent c068722 commit ece560c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Sources/Forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,18 @@ protected static function findAction(?string $action): string|callable|false
{
// If no action was supplied, is there an implied action?
if (empty($action)) {
// Action and board are both empty... BoardIndex!
if (empty(Board::$info->id) && empty(Topic::$topic_id)) {
// ... unless someone else wants to do something different.
// We check $_GET['topic'] and $_GET['board'] because the implied
// action depends on what was in the URL, not on whatever values we
// calculated for Board::$info->id and Topic::$info->id. This means
// that if $_GET['topic'] or $_GET['board'] are set to something
// invalid, an error will be shown. This is the correct and intended
// behaviour.
if (isset($_GET['topic'])) {
$action = 'display';
} elseif (isset($_GET['board'])) {
$action = 'messageindex';
} else {
// Does a mod want to change the default action?
if (!empty(Config::$modSettings['integrate_default_action'])) {
$default_action = explode(',', Config::$modSettings['integrate_default_action'])[0];

Expand All @@ -715,14 +724,6 @@ protected static function findAction(?string $action): string|callable|false

$action = 'boardindex';
}
// Topic is empty, and action is empty.... MessageIndex!
elseif (empty(Topic::$topic_id)) {
$action = 'messageindex';
}
// Board is not empty... topic is not empty... action is empty... Display!
else {
$action = 'display';
}
}

// Still no valid action?
Expand Down

0 comments on commit ece560c

Please sign in to comment.