-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Added a switch to delete file after the response is send #11212
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] Added a switch to delete file after the response is send #11212
Conversation
@@ -289,4 +296,14 @@ public static function trustXSendfileTypeHeader() | |||
{ | |||
self::$trustXSendfileTypeHeader = true; | |||
} | |||
|
|||
/** | |||
* If this is set to true, the file will be unlinked after the request is send |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be a mention that this will not delete the file when relying on X-Sendfile
I have made the necessary changes and added a pull request for the documentation. |
I fixed the doc PR reference to make it point to the doc repo, not to a different PR on the code. the reference should be fixed in the doc PR as well (but I cannot do it as I'm not part of the doc team and I'm not the PR author) |
Thank you, I have updated the reference in the symfony-docs PR. |
Added @return in PHPDoc and added PHPUnit test. Should be OK to merge. |
👍 |
1 similar comment
👍 |
@@ -46,6 +47,8 @@ public function __construct($file, $status = 200, $headers = array(), $public = | |||
{ | |||
parent::__construct(null, $status, $headers); | |||
|
|||
$this->deleteFileAfterSend = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be set already in variable declaration?
protected $deleteFileAfterSend = false;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be more consistent indeed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable is now set on declaration.
Variable initialization moved from constructor to field declaration. I think the Travis build failure did not have anything to do with my code.
|
👍 |
Thank you @WybrenKoelmans. |
…he response is send (WybrenKoelmans) This PR was merged into the 2.6-dev branch. Discussion ---------- [HttpFoundation] Added a switch to delete file after the response is send | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | symfony/symfony-docs#3975 I have not done any Unit Tests for this code as I suspect there may already be a way to solve my problem of deleting a file after the request was sent. Is it possible to use `sendContent` and delete the file after that? My attempts were unsuccessful. If this code is desirable, please assist me in how I would write an unit test for this. Thanks. TODO: - [x] Add unit tests - [x] Update documentation - [x] Mention that using `X-Sendfile` will overwrite deleteFileAfterSend Commits ------- 1fff158 [HttpFoundation] Added a switch to delete file after the response is send
I have not done any Unit Tests for this code as I suspect there may already be a way to solve my problem of deleting a file after the request was sent. Is it possible to use
sendContent
and delete the file after that? My attempts were unsuccessful.If this code is desirable, please assist me in how I would write an unit test for this. Thanks.
TODO:
X-Sendfile
will overwrite deleteFileAfterSend