refactor(base): decompose initSession() into focused private helper methods#60754
Open
joshtrichards wants to merge 12 commits into
Open
refactor(base): decompose initSession() into focused private helper methods#60754joshtrichards wants to merge 12 commits into
joshtrichards wants to merge 12 commits into
Conversation
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>
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
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
cookie_domain. Also used a hardcoded-1expiry. Now usessession_get_cookie_params()to match the original cookie's path and domain, and a standard$now - 3600expiry.$_COOKIEdirectly.$_COOKIE['nc_session_id']replaced with$request->getCookie('nc_session_id')for consistency and testability.LAST_ACTIVITYvalidation 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)increateWrappedSession()should probably be widened to\Throwable— noted with a TODO comment for nowChecklist
3. to review, feature component)stable32)AI (if applicable)