8000 [HttpFoundation] Added a switch to delete file after the response is send by WybrenKoelmans · Pull Request #11212 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Merged
merged 1 commit into from
Jul 9, 2014
Merged

[HttpFoundation] Added a switch to delete file after the response is send #11212

merged 1 commit into from
Jul 9, 2014

Conversation

WybrenKoelmans
Copy link
Contributor
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:

  • Add unit tests
  • Update documentation
  • Mention that using X-Sendfile will overwrite deleteFileAfterSend

@@ -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
Copy link
Member

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

@WybrenKoelmans
Copy link
Contributor Author

I have made the necessary changes and added a pull request for the documentation.

@stof
Copy link
Member
stof commented Jun 24, 2014

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)

@WybrenKoelmans
Copy link
Contributor Author

Thank you, I have updated the reference in the symfony-docs PR.

@WybrenKoelmans
Copy link
Contributor Author

Added @return in PHPDoc and added PHPUnit test.

Should be OK to merge.

@fabpot
Copy link
Member
fabpot commented Jul 4, 2014

👍

1 similar comment
@stof
Copy link
Member
stof commented Jul 4, 2014

👍

@@ -46,6 +47,8 @@ public function __construct($file, $status = 200, $headers = array(), $public =
{
parent::__construct(null, $status, $headers);

$this->deleteFileAfterSend = false;
Copy link
Contributor

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;

Copy link
Member

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

8000
Copy link
Contributor Author

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.

@WybrenKoelmans
Copy link
Contributor Author

Variable initialization moved from constructor to field declaration.

I think the Travis build failure did not have anything to do with my code.

PHP Fatal error:  Class 'Psr\Log\LogLevel' not found in /home/travis/build/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php on line 522

#11332

@romainneutron
Copy link
Contributor

👍

@fabpot
Copy link
Member
fabpot commented Jul 9, 2014

Thank you @WybrenKoelmans.

@fabpot fabpot merged commit 1fff158 into symfony:master Jul 9, 2014
fabpot added a commit that referenced this pull request Jul 9, 2014
…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
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
0