When using php redis as a session handler with session locking if there is an error where a lock cannot happen a php notice is thrown and the script continues. Is there a way to configure it for a fatal error and the script NOT process at all?
When using php redis as a session handler with session locking if there is an error where a lock cannot happen a php notice is thrown and the script continues. Is there a way to configure it for a fatal error and the script NOT process at all?
2
Answers
In case anyone wants to know the exact code for turning session_lock notice into fatal error; here it is. (I couldn't have done it without the other answer, but this is exactly what I used)
Make sure that you follow this documentation statement:
If you still have some problems then a quick fix for whole application could be set your own error handler with set_error_handler that takes care for that particular problem.
An example handler below that reacts only to using not declared variable. Change the regex pattern so it matches your Redis error msg.
the last line
ends script with info:
set_error_handler should be used at the beginning of your php script (perfectly inside a common file that is required everywhere like a bootstrap.php)
The downside of using your own error handler is that if you work with a framework or other wrapping code it might already set its own error handler that provides some useful features like debugging or maybe even that error handler is essential to that framework error handling, logging etc.
If you wish to restore to original error handler (that default from PHP or the one that was set before your own) use restore_error_handler