You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting the following exceptions in a slim APP in some random cases.
The exception thrown on the line above is redundant and causes more harm than it helps.
The correct code should be something like so (with no exceptions thrown):
if (!$options['cacheDisabled'] && file_exists($options['cacheFile'])) {
$dispatchData = require $options['cacheFile'];
if (is_array($dispatchData)) {
return new $options['dispatcher']($dispatchData);
}
// Cache file is corrupted, so delete it and regenerate it below.
@unlink($options['cacheFile']);
}
The only issues I can think of are race conditions during the cache file regeneration that are not handled in the code in any way at the moment. The new solution will cause a stampede of the cache, where the old one will throw an exception that can cause a fatal because of a cache layer (should not happen).
In short if there is a cache and it is valid (an array) - use that.
If there is an invalid file - delete it and proceed with regenerating it during the request.
The text was updated successfully, but these errors were encountered:
FastRoute/src/functions.php
Line 58 in 7723b1d
I am getting the following exceptions in a slim APP in some random cases.
The exception thrown on the line above is redundant and causes more harm than it helps.
The correct code should be something like so (with no exceptions thrown):
The only issues I can think of are race conditions during the cache file regeneration that are not handled in the code in any way at the moment. The new solution will cause a stampede of the cache, where the old one will throw an exception that can cause a fatal because of a cache layer (should not happen).
In short if there is a cache and it is valid (an array) - use that.
If there is an invalid file - delete it and proceed with regenerating it during the request.
The text was updated successfully, but these errors were encountered: