Skip to content

[HttpFoundation] Add File\Stream for size-unknown BinaryFileResponse #21188

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
Jan 9, 2017

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jan 6, 2017

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #19738
License MIT
Doc PR symfony/symfony-docs#7343

Replaces #19740. Native "getSize" is reported to return false on error, so using false as return type doesn't break the signature.

public function getSize()
{
return false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that this a the best solution. Returning false is not covered by the documentation. What if we removed the method here and then used some kind of instanceof Stream check when handling the response instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a doc issue. Looking at the source, getSize is just the same as filesize, or 'size' as returned by fstat.
Here is the doc for filesize that tells about false: http://php.net/filesize
This means that we have to handle false here, regardless of Stream.

Copy link
Member

@xabbuh xabbuh Jan 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense then. However, did you manage to call getSize() without getting a warning in that case? Otherwise, we may want to silence the operation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, let's wait an issue report if that ever happens :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah well I see that we already throw an exception when the file does not exist.

@xabbuh
Copy link
Member

xabbuh commented Jan 8, 2017

👍

Status: Reviewed

@javiereguiluz
Copy link
Member

👍

*
* @author Nicolas Grekas <p@tchwork.com>
*/
class Stream extends File
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this file be moved as a fixture file instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is the feature :)

@fabpot
Copy link
Member

fabpot commented Jan 8, 2017

Can you add a not in the CHANGELOG and submit a PR on the docs?

@nicolas-grekas
Copy link
Member Author

@fabpot done

@@ -4,6 +4,7 @@ CHANGELOG
3.3.0
-----

* added the `File\Stream` class for size-unknown `BinaryFileResponse`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to be more explicit about the use-case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better now?

@fabpot
Copy link
Member

fabpot commented Jan 9, 2017

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 8011209 into symfony:master Jan 9, 2017
fabpot added a commit that referenced this pull request Jan 9, 2017
…ryFileResponse (nicolas-grekas)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[HttpFoundation] Add File\Stream for size-unknown BinaryFileResponse

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19738
| License       | MIT
| Doc PR        | symfony/symfony-docs#7343

Replaces #19740. Native "getSize" is reported to return false on error, so using false as return type doesn't break the signature.

Commits
-------

8011209 [HttpFoundation] Add File\Stream for size-unknown BinaryFileResponse
@nicolas-grekas nicolas-grekas deleted the bin-stream-chunk branch January 9, 2017 14:39
@fabpot fabpot mentioned this pull request May 1, 2017
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.

5 participants