Commit 9b2c2a4
committed
bug symfony#52502 [Config] Prefixing
This PR was submitted for the 6.3 branch but it was merged into the 5.4 branch instead.
Discussion
----------
[Config] Prefixing `FileExistenceResource::__toString()` to avoid conflict with `FileResource`
| Q | A
| ------------- | ---
| Branch? | 6.3
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fixes issue in AssetMapper 6.4
| License | MIT
Hi!
This bug causes a pretty critical AssetMapper 6.4 bug. The problem is that both `FileResource` and `FileExistenceResource` return the same `__toString()` for the same file:
* [FileResource::__toString()](https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Config/Resource/FileResource.php#L43-L46)
* [FileExistenceResource::__toString()](https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Config/Resource/FileExistenceResource.php#L39-L41)
[SelfCheckingResourceChecker](https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Config/Resource/SelfCheckingResourceChecker.php#L40-L45) uses a static cache where the `ResourceInterface::__toString()` is the key for that string. That creates the following bug situation:
A) Something checks for `FileExistenceResource` for `foo/bar.php`. This returns true and `SelfCheckingResourceChecker` now has `true` for fresh in its static cache
B) Something else checks for `FileResource` for `foo/bar.php`: they are checking to see if the file has been *modified*. But in instead of calling the actual `FileResource::isFresh()` method, it uses the `true` value from the static cache.
Cheers!
Commits
-------
9e8db58 [Config] Prefixing FileExistenceResource::__toString() to avoid conflict with FileResourceFileExistenceResource::__toString() to avoid conflict with FileResource (weaverryan)File tree
2 files changed
+2
-2
lines changed- src/Symfony/Component/Config
- Resource
- Tests/Resource
2 files changed
+2
-2
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
0 commit comments