Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #58712 [HttpFoundation] Fix support for
\SplTempFileObject
in `…
…BinaryFileResponse` (elementaire) 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 | #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 ------- a104d50cb7a Fix support for \SplTempFileObject in BinaryFileResponse
- Loading branch information