Skip to content

[3.0] Let the news feed run without a current board - #9411

Merged
Sesquipedalian merged 2 commits into
SimpleMachines:release-3.0from
albertlast:3.0/feed-news-no-board
Aug 14, 2026
Merged

[3.0] Let the news feed run without a current board#9411
Sesquipedalian merged 2 commits into
SimpleMachines:release-3.0from
albertlast:3.0/feed-news-no-board

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

?action=.xml;sa=news is an error page on every forum unless it is scoped to a board:

Typed static property SMF\Board::$info must not be accessed before initialization
                                                    Sources/Actions/Feed.php:748

getXmlNews() puts Board::$info->id straight into the query parameters:

[
	'current_board' => Board::$info->id,
	'is_approved' => 1,
	…
]

The WHERE clause only uses that parameter when there is a board, and the conditions deciding it go through empty(), which tolerates an uninitialised typed property:

(empty(Board::$info->id) ? '' : '
	AND t.id_board = {int:current_board}')

The parameter array does not — it reads the property outright, and a feed for the whole forum has no current board to read. So the site-wide news feed dies while the per-board one works.

getXmlRecent(), a few hundred lines further down in the same file, already does it the right way, and this now matches:

$current_board = isset(Board::$info) ? Board::$info->id : 0;
Checked

As a guest on the running forum, before:

?action=.xml;sa=news             → "An error has occurred", 0 items
?action=.xml;sa=news;board=1     → 1 item

after:

?action=.xml;sa=news             → 5 <item>
?action=.xml;sa=news;board=1     → items
?action=.xml;sa=news;type=atom   → <entry>
?action=.xml;sa=recent           → items

This one is worth a second look precisely because phplint and php-cs-fixer both pass on it and nothing in the codebase reads the feed — it only fails when something asks for the URL. Found by sweeping a stock forum's pages as a guest; every earlier sweep in this series ran as an admin and never requested it.

Issues References (Fixes|Related|Closes)

Related to #7933

?action=.xml;sa=news is an error page unless it is scoped to a board:

  Typed static property SMF\Board::$info must not be accessed before
  initialization                                Sources/Actions/Feed.php:748

getXmlNews() puts Board::$info->id into the query parameters unconditionally.
The WHERE clause only uses it when there is a board, and the conditions that
decide that go through empty(), which tolerates an uninitialised typed
property. The parameter array does not: it reads it outright, and a feed for
the whole forum has no current board to read.

getXmlRecent(), a few hundred lines further down, already works around this
the right way, so this does the same thing:

  $current_board = isset(Board::$info) ? Board::$info->id : 0;

Signed-off-by: Mathias Papenbrock <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Comment thread Sources/Actions/Feed.php Outdated
Comment thread Sources/Actions/Feed.php Outdated
Co-authored-by: Jon Stovell <jonstovell@gmail.com>
@Sesquipedalian
Sesquipedalian merged commit cb4b1c0 into SimpleMachines:release-3.0 Aug 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Web feeds RSS, ATOM, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants