Move delayed transaction finisher state out of middleware #936
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.
Because out middleware is a singleton resolved in the boot of the framework it never get's detroyed so any state remains forever, this caused the terminating callback to only be registered for one request and subsequent requests did not get a new terminating callback registered. To fix this I moved the registering of the callback to a class we keep as a singleton so we know if the container was reset and this ensure the callback is only registered once per container lifecycle and re-registers it as needed for Octane.
Fixes #935
This also works fine on normal Laravel applications. Lumen never used this method anyway since
app()->terminating()
isn't a thing there.