Skip to content

refactor(base): decompose initSession() into focused private helper methods#60754

Open
joshtrichards wants to merge 12 commits into
masterfrom
jtr/refactor-base-initSession
Open

refactor(base): decompose initSession() into focused private helper methods#60754
joshtrichards wants to merge 12 commits into
masterfrom
jtr/refactor-base-initSession

Conversation

@joshtrichards
Copy link
Copy Markdown
Member

  • Resolves: #

Summary

This PR refactors OC::initSession() out into smaller, focused private helpers to improve readability and testability. No behavior is changed beyond several fixes I judged low-risk/high confidence (noted below).

Bug/robustness fixes included

  • Session cookie deletion now includes the configured domain. Previously omitted the domain, meaning the cookie might not be cleared on instances with a configured cookie_domain. Also used a hardcoded -1 expiry. Now uses session_get_cookie_params() to match the original cookie's path and domain, and a standard $now - 3600 expiry.
  • DAV bypass no longer reads $_COOKIE directly. $_COOKIE['nc_session_id'] replaced with $request->getCookie('nc_session_id') for consistency and testability.
  • LAST_ACTIVITY validation hardened. Non-numeric and non-positive values are now rejected before the timeout comparison, preventing unintended session invalidation on corrupt session data. (Aside: We may want to add debug level logging when this happens I guess so there's at least some chance of discovering it in the wild).

Known follow-up (not in this PR)

  • catch (Exception $e) in createWrappedSession() should probably be widened to \Throwable — noted with a TODO comment for now

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
…or time

- Document edge cases / robustness matters that are important but may need to wait until after the general refactor is merged/tested
- Also go ahead fix this low-risk one: capture `$now` for all time-based decisions to make the logic more consistent, simplify future testing, and avoid tidy edge inconsistencies

Signed-off-by: Josh <josh.t.richards@gmail.com>
Currently disabled but unless we're dropping the code outright, stashes it in a helper where it belongs.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards added 2. developing Work in progress feature: authentication technical debt 🧱 🤔🚀 ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) 3. to review Waiting for reviews and removed 2. developing Work in progress labels May 27, 2026
@joshtrichards joshtrichards marked this pull request as ready for review May 27, 2026 21:34
@joshtrichards joshtrichards requested a review from a team as a code owner May 27, 2026 21:34
@joshtrichards joshtrichards requested review from ArtificialOwl, CarlSchwan, leftybournes and provokateurin and removed request for a team May 27, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews feature: authentication ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) technical debt 🧱 🤔🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant