-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Actually fix GH-9583 #9638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Actually fix GH-9583 #9638
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That actually looks correct. While I don't like to refer to mod_user_names
in session.c, that ship has obviously sailed long ago. However, the implementation of session_regenerate_id()
might also need that hack:
Lines 2250 to 2270 in 8e1cef4
PS(id) = PS(mod)->s_create_sid(&PS(mod_data)); | |
if (!PS(id)) { | |
PS(session_status) = php_session_none; | |
if (!EG(exception)) { | |
zend_throw_error(NULL, "Failed to create new session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path)); | |
} | |
RETURN_THROWS(); | |
} | |
if (PS(use_strict_mode) && PS(mod)->s_validate_sid && | |
PS(mod)->s_validate_sid(&PS(mod_data), PS(id)) == SUCCESS) { | |
zend_string_release_ex(PS(id), 0); | |
PS(id) = PS(mod)->s_create_sid(&PS(mod_data)); | |
if (!PS(id)) { | |
PS(mod)->s_close(&PS(mod_data)); | |
PS(session_status) = php_session_none; | |
if (!EG(exception)) { | |
zend_throw_error(NULL, "Failed to create session ID by collision: %s (path: %s)", PS(mod)->s_name, PS(save_path)); | |
} | |
RETURN_THROWS(); | |
} | |
} |
Otherwise we would always create the session ID twice for mod_user.
Oh, and please delete the comment |
The issue is that PS(mod)->s_validate_sid is always defined for user modules, thus we need to check that the actual callable is set Add another regression test to ensure current working behaviour is not broken (which was by the previous incorrect fix)
39e7219
to
0c07c55
Compare
I'm very confused by the whole check here... at it seems to be kinda weirdly implemented? I tried to fix it let me know what you think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks good to me. Thank you!
This PR was merged into the 4.4 branch. Discussion ---------- [HttpFoundation] Fix session tests | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Spotted after php/php-src#9638 The `validateId()` method of session handlers should return true only when the session-id maps to actual data in the storage. This behavior was not correctly mocked in our function tests. Commits ------- c594f5d [HttpFoundation] Fix session tests
The issue is that PS(mod)->s_validate_sid is always defined for user modules, thus we need to check that the actual callable is set Add another regression test to ensure current working behaviour is not broken (which was by the previous incorrect fix)