Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 30a02c4

Browse filesBrowse files
bug #53701 [AssetMapper] Fix exception if assets directory is missing in production (rynhndrcksn)
This PR was merged into the 6.4 branch. Discussion ---------- [AssetMapper] Fix exception if assets directory is missing in production | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #53669 | License | MIT 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 empty `assets/` 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 their `production` environments. Commits ------- 962a044 Fix exception if assets dir is missing in prod
2 parents 4fe7828 + 962a044 commit 30a02c4
Copy full SHA for 30a02c4

File tree

Expand file treeCollapse file tree

2 files changed

+6
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-2
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
param('kernel.project_dir'),
7676
abstract_arg('array of excluded path patterns'),
7777
abstract_arg('exclude dot files'),
78+
param('kernel.debug'),
7879
])
7980

8081
->set('asset_mapper.public_assets_path_resolver', PublicAssetsPathResolver::class)

‎src/Symfony/Component/AssetMapper/AssetMapperRepository.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/AssetMapper/AssetMapperRepository.php
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct(
3434
private readonly string $projectRootDir,
3535
private readonly array $excludedPathPatterns = [],
3636
private readonly bool $excludeDotFiles = true,
37+
private readonly bool $debug = false
3738
) {
3839
}
3940

@@ -147,7 +148,7 @@ private function getDirectories(): array
147148
$this->absolutePaths = [];
148149
foreach ($this->paths as $path => $namespace) {
149150
if ($filesystem->isAbsolutePath($path)) {
150-
if (!file_exists($path)) {
151+
if (!file_exists($path) && $this->debug) {
151152
throw new \InvalidArgumentException(sprintf('The asset mapper directory "%s" does not exist.', $path));
152153
}
153154
$this->absolutePaths[realpath($path)] = $namespace;
@@ -161,7 +162,9 @@ private function getDirectories(): array
161162
continue;
162163
}
163164

164-
throw new \InvalidArgumentException(sprintf('The asset mapper directory "%s" does not exist.', $path));
165+
if ($this->debug) {
166+
throw new \InvalidArgumentException(sprintf('The asset mapper directory "%s" does not exist.', $path));
167+
}
165168
}
166169

167170
return $this->absolutePaths;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.