fix(core): keep Horde_Session::$begin readable after close() (imp#88)#197
Merged
Merged
Conversation
Read-only service scripts (the attachment download service, and potentially other read-only endpoints) call close() right after session bootstrap. close() flips the legacy Horde_Session shims `_active` flag to false but never clears the underlying session data - the modern HordeSession keeps it intact. Horde_Session::__get(begin) short-circuited to 0 whenever `_active` was false, so Registry::checkExistingAuth()s `session.max_time` check (`max_time + $session->begin < time()`) incorrectly rejected every closed, read-only request once session.max_time was configured: max_time + 0 is always less than the current Unix timestamp. That produced "User is not authenticated" on attachment downloads even for a fully logged-in user. Read through to the modern HordeSession unconditionally instead - its data survives close() untouched. Add HordeSessionShimBeginTest covering both the post-close and never-started cases.
ralflang
approved these changes
Jul 10, 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.
Summary
Horde_Session::$beginreturning0afterclose(), which broke thesession.max_timeauth check for read-only service scripts.Motivation
Reported in horde/imp#88: downloading an attachment in IMP returned a 500 (
IMP_Exception: User is not authenticated.), even for a fully logged-in user. The attachment download service boots with a read-only session and callsclose()right after bootstrap.Horde_Session::__get('begin')returned0whenever the shim's_activeflag was false - whichclose()sets, without clearing the underlying session data.Horde_Registry::checkExistingAuth()uses$session->beginfor thesession.max_timecheck:With
begincollapsed to0,max_time + 0is always less than the current Unix timestamp, so this check failed unconditionally for every closed, read-only request oncesession.max_timewas configured - regardless of how recently the user actually authenticated.Changes
Horde_Session::__get('begin')now reads through to the modernHordeSessionunconditionally. Its data survivesclose()untouched, so this is safe for both the closed-but-was-active case and the never-started case (falls back to0via the existingnullhandling).HordeSessionShimBeginTestcovering both cases.Test plan
vendor/bin/phpunit test/Unit/Session/HordeSessionShimBeginTest.php(2/2 passing)