Skip to content
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

[ HttpFoundation ] BinaryFileResponse sends empty file. #28268

Closed
wants to merge 1 commit into from
Closed

[ HttpFoundation ] BinaryFileResponse sends empty file. #28268

wants to merge 1 commit into from

Conversation

j4nr6n
Copy link
Contributor

@j4nr6n j4nr6n commented Aug 26, 2018

Q A
Branch? 3.4
Bug fix? yes?
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes, with the exception of preexisting, unrelated failures
Fixed tickets #28237
License MIT
Doc PR

When you call BinaryFileResponse#sendContent() without first calling prepare() the response is sent but the contents are empty. prepare() properly initializes the $maxlen and $offset properties. However, sendContent() doesn't do any sanity checking, and so, uses the uninitialized properties. This causes stream_copy_to_stream() to copy empty contents and the file that is sent, to contain nothing.

This change initializes the properties at definition instead of in prepare().

Additionally:

  • Bug fixes must be submitted against the lowest branch where they apply

I'm not sure how early this bug exists, or how far back to go. I'll check to see if 2.7 and 2.8 are affected and report back.

@j4nr6n
Copy link
Contributor Author

j4nr6n commented Aug 26, 2018

Test app, for reference

@j4nr6n
Copy link
Contributor Author

j4nr6n commented Aug 26, 2018

See #28278

@j4nr6n j4nr6n closed this Aug 26, 2018
@j4nr6n j4nr6n deleted the issue_28237 branch August 26, 2018 16:36
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.

None yet

2 participants