Commit 4829c82
committed
bug symfony#58712 [HttpFoundation] Fix support for
This PR was merged into the 7.1 branch.
Discussion
----------
[HttpFoundation] Fix support for `\SplTempFileObject` in `BinaryFileResponse`
| Q | A
| ------------- | ---
| Branch? | 7.1
| Bug fix? | yes
| PR original Feature | symfony#49144
| New feature? | no
| Deprecations? | no
| Issues | -
| License | MIT
We can not call some methods with an object of `\SplTempFileObject()`. We get this error: `[...] stat failed for php://temp`.
I have checked the code against methods listed in [this note](https://www.php.net/manual/en/class.spltempfileobject.php#128962).
I have found:
- `getMTime()` called in `BinaryFileResponse::setAutoLastModified()`
- `getSize()` called in `BinaryFileResponse::prepare()`
- `isReadable()` called in `BinaryFileResponse::setFile()` (already safe)
I have updated the unit test and patched the class `BinaryFileResponse`.
Note: calling `SplFileObject::fstat()` gives `mtime` equals to `0`. I think it is nonsense to use that as value for last modified. I have decided to use `time()` because i guess, we can not do better. Indeed, we have no idea how much time have passed between making the temp file and the call to `setAutoLastModified()` by the developper.
Commits
-------
a104d50 Fix support for \SplTempFileObject in BinaryFileResponse\SplTempFileObject in BinaryFileResponse (elementaire)File tree
2 files changed
+7
-2
lines changed- src/Symfony/Component/HttpFoundation
- Tests
2 files changed
+7
-2
lines changedLines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
201 | 203 | | |
202 | 204 | | |
203 | 205 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
454 | 457 | | |
455 | 458 | | |
456 | 459 | | |
| |||
0 commit comments