-
Notifications
You must be signed in to change notification settings - Fork 8k
ext/session: only return false when could not encode session at all #21181
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
base: master
Are you sure you want to change the base?
ext/session: only return false when could not encode session at all #21181
Conversation
This also fixes bug 71162
| // TODO warn that ID cannot be verified? else { } | ||
| } | ||
| /* Read is required to make new session data at this point. */ | ||
| zend_string *data; |
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.
I think it should be initialised to NULL wdyt ?
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.
Hm, it wasn't previously though, so is that a bug then do 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.
not sure all callbacks guarantee initialisation, this is all I m saying but I do not session that well :)
| smart_str_appendc(&buf, PS_DELIMITER); | ||
| php_var_serialize(&buf, struc, &var_hash); | ||
| ); | ||
| PHP_VAR_SERIALIZE_DESTROY(var_hash); |
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.
This introduces a bug: now var_hash is destroyed twice because it is already destroyed at line 1039 too. I think you may drop line 1039.
| // TODO warn that ID cannot be verified? else { } | ||
| } | ||
| /* Read is required to make new session data at this point. */ | ||
| zend_string *data; |
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.
Hm, it wasn't previously though, so is that a bug then do you think?
This also fixes bug 71162.
I'm targeting master with this change as it is long-standing behaviour, but I don't really understand why an "empty session" would fail to encode. Similarly, with a "partial" encoding of it when discarding numeric keys.
The biggest impact is that
session_encode()now only returnsfalsein very limited cases and for empty sessions returns an empty string, which is how it was encoded anyway when actually performing session writes.