Session: keep exceptions chain on session_start #240
Merged
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.
There was an issue #208 - phpredis session driver was raising a notice, when session lock can't be obtained. Nette Session was correctly converting this notice to an exception. The strange was, that even the notice was raised,
session_start
returnedtrue
(it was phpredis problem).Now, the new production version of phpredis is out, and the behavior is a little bit different. If a lock can't be obtained, instead of notice, the warning (instead of a notice) is raised and the
session_start
returned correctlyfalse
.The problem is, I need to know the reason why the session wasn't started (when redis is death, it's a problem, when session lock can't be obtained, it's probably OK - user is probably doing many parallel requests).
Nette\Utils\Callback::invokeSafe
around thesession_start
method correctly converts warnings to exceptions, but now, there are two exceptions:Failed to acquire session lock
Failed to read session data: redis (path: tcp://server:6379?timeout=3&database=1&prefix=session:v1:)
And the first one is overwritten with the second one, that is thrown to the app. But I need to know also the first one :-)
So my first idea is to set correct
previous
exception property and in the app, I have the complete exceptions chain, that I can read and get the correct session problem.