Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation] Fix support for \SplTempFileObject in BinaryFileResponse #58712

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

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

elementaire
Copy link
Contributor

@elementaire elementaire commented Oct 29, 2024

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.

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.

@carsonbot carsonbot added this to the 7.1 milestone Oct 29, 2024
@elementaire elementaire changed the title [HttpFoundation] Fix support for \SplTempFileObject in BinaryFileResponse [HttpFoundation] Fix support for \SplTempFileObject in BinaryFileResponse Oct 29, 2024
@elementaire elementaire force-pushed the fix-binaryfileresponse branch from 21b6c7b to a104d50 Compare November 4, 2024 20:17
@nicolas-grekas
Copy link
Member

Thank you @elementaire.

@nicolas-grekas nicolas-grekas merged commit 4829c82 into symfony:7.1 Nov 5, 2024
9 of 10 checks passed
This was referenced Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants