Commit 4095bcc
committed
bug #42033 [HttpFoundation] Fix deleteFileAfterSend on client abortion (nerg4l)
This PR was squashed before being merged into the 4.4 branch.
Discussion
----------
[HttpFoundation] Fix deleteFileAfterSend on client abortion
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets | Fix #27538 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
| Doc PR | <!-- required for new features -->
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.
Additionally (see https://symfony.com/releases):
- Always add tests and ensure they pass.
- Never break backward compatibility (see https://symfony.com/bc).
- Bug fixes must be submitted against the lowest maintained branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too.)
- Features and deprecations must be submitted against branch 5.x.
- Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
-->
**Description**
If someone sets `deleteFileAfterSend` to `true` for a `BinaryFileResponse` instance they expect the file to be deleted when the response finished. This is not the case when the response is cancelled because PHP won't continue running the code. `ignore_user_abort` can be used to allow it to finish but this means `stream_copy_to_stream` will also continue to run regardless of the abort. To fix this later problem it can be a solution to run the copy in a loop and detect the connect abort manually with `connection_aborted`.
**Tests**
I don't know how can I simulate connection abort in PHPUnit. I would appreciate if I could get some guidance if it is possible.
**Todo**
- [ ] add tests if connection abort can be simulated
- [ ] gather feedback for my changes
Commits
-------
f097bef6d4 [HttpFoundation] Fix deleteFileAfterSend on client abortion1 file changed
+34
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
127 | 144 | | |
128 | 145 | | |
129 | 146 | | |
| |||
303 | 320 | | |
304 | 321 | | |
305 | 322 | | |
306 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
307 | 340 | | |
308 | 341 | | |
309 | 342 | | |
| |||
0 commit comments