Fix path resolution during optimize with Sentry#88
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The scenario
Running
php artisan optimizewith Sentry installed produces broken compiled templates — components aren't compiled to functions.Running
php artisan view:cachealone works fine.The problem
app('blade.compiler')->getPath()always returnsnullduringoptimize, so we skip thewrap()call entirely. This happens because the instance resolved viaapp('blade.compiler')is different from the one that started view compilation.Sentry forces early resolution of the blade engine during boot via
app('view')->getEngineResolver()->resolve('blade'). Whenphp artisan optimizeruns:config:cache— swaps the application instance in the container.view:cache— compiles views using the original app instance from$this->laravel.Because of the early resolution, Laravel doesn't resolve the blade compiler again from the new instance and instead uses the stale one. Calling
app('blade.compiler')returns a new instance that has no path set.The solution
We capture the compiler reference once in
BladeService::earliestPreCompilationHook()and thread$paththrough the entire blaze pipeline, instead of resolvingapp('blade.compiler')inside eachBlazeManagermethod:Fixes #43