-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[AssetMapper] Fix exception if assets directory is missing in production #53701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AssetMapper] Fix exception if assets directory is missing in production #53701
Conversation
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php
Outdated
Show resolved
Hide resolved
With this PR, if someone runs the following command what would happen, exceptions would not be thrown if some directory is missing ?
|
79e49d8
to
962a044
Compare
@smnandre I've attached 2 screenshots of what happens when the If the ![]() If the ![]() So during the deployment/asset compilation process people will still be notified if the |
Perfect for me, thank you very much 👍 |
Thank you @rynhndrcksn. |
@@ -34,6 +34,7 @@ public function __construct( | |||
private readonly string $projectRootDir, | |||
private readonly array $excludedPathPatterns = [], | |||
private readonly bool $excludeDotFiles = true, | |||
private readonly bool $debug = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set this to true by default in aa469d9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I did that locally while my project was set to prod
mode, it causes Symfony to crash and return a 500 error.

Is it possible that param('kernel.debug'),
(link to line) isn't passing in false
when the site is in prod
mode, making AssetMapperRepository.php
default to true, making it so the $this->debug
checks succeed while the site is in prod
mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can still use the prod environment in debug mode if you want locally. The prod environment defaults to non-debug mode, but the APP_DEBUG
env variable still wins over this default.
During deployment some people will compile their assets with Asset Mapper then delete the root
assets/
directory. This causes Asset Mapper to throw an exception, and a common work around people mentioned in the issue is to create an emptyassets/
directory.This PR makes it so the exception is only thrown while
kernel.debug
is equal to true, letting developers know locally that there's an issue, but allowing people to safely do this in theirproduction
environments.