[2.x] fix: guard against missing session in FlarumDataSource::getSessionData() - #43
Merged
DavideIadeluca merged 1 commit intoAug 27, 2026
Conversation
Requests that never pass through StartSession (e.g. token-authenticated API requests) have no 'session' attribute, so $session->all() throws "Call to a member function all() on null". Return an empty array when the request has no session. Also fixes method name casing (getattribute -> getAttribute). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gianniguida
force-pushed
the
fix/null-session-2x
branch
from
August 27, 2026 07:30
c4e4976 to
590b8c5
Compare
DavideIadeluca
approved these changes
Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
FlarumDataSource::getSessionData()assumes every profiled request carries asessionattribute. Requests that never pass throughStartSession— token-authenticated API requests being the common case — have no session, so$session->all()throws:On a production forum with an API monitoring probe (Zabbix hitting a healthcheck endpoint with an
Authorizationheader) this fires on every poll interval and floods error tracking. Any headless API consumer using token auth triggers the same error.Fix
Return an empty array when the request has no session, mirroring the fact that sessions are optional on Flarum's PSR-7 requests. Also fixes method name casing (
getattribute→getAttribute) — functionally identical, but it defeats IDE navigation and static analysis.Testing
Verified against a local Flarum 1.x forum (Docker) with fof/clockwork 1.1.1 (the same code path exists unchanged on 2.x) enabled and the requesting user in the admin group (so the Clockwork authenticator lets the request be profiled):
curl -H "Authorization: Token <key>" http://localhost:8000/api/discussions?page[limit]=1(no cookies) → HTTP 500, withflarum.ERROR: Error: Call to a member function all() on null in .../fof/clockwork/src/Clockwork/FlarumDataSource.phpin the forum log."sessionData": [].🤖 Generated with Claude Code