-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] moved file hash calculation to own method #6708
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
Conversation
IMO it's looks a like overkill... |
hmm yeah .. seems like something that could be done via inheritance .. |
I agree, overriting the method is much simpler solution. |
Besides the |
* | ||
* @return string | ||
*/ | ||
protected function calculateFileHash() |
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.
I would have injected the file path as an argument, that makes the method independent of the way we store the file path.
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.
done.
@@ -123,12 +124,25 @@ public function setAutoLastModified() | |||
*/ | |||
public function setAutoEtag() | |||
{ | |||
$this->setEtag(sha1_file($this->file->getPathname())); | |||
$hash = $this->calculateFileHash($this->file->getPathname()); |
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.
No real reason to introduce one time variable.
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.
done :)
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #6708). Commits ------- 90a3e7a [HttpFoundation] moved file hash calculation to own method Discussion ---------- [HttpFoundation] moved file hash calculation to own method Bug fix: no Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Todo: - Fixes the following tickets: #6101 License of the code: MIT Documentation PR: - This commit adds ability to change default hashing implementation by extending BinaryFileResponse. --------------------------------------------------------------------------- by stloyd at 2013-01-11T16:23:30Z IMO it's looks a like overkill... --------------------------------------------------------------------------- by lsmith77 at 2013-01-11T16:39:33Z hmm yeah .. seems like something that could be done via inheritance .. --------------------------------------------------------------------------- by Tobion at 2013-01-11T17:44:29Z I agree, overriting the method is much simpler solution. --------------------------------------------------------------------------- by jalliot at 2013-01-11T18:16:04Z Besides the `$autoetag` variable is false by default so you have to explicitly enable this behavior... --------------------------------------------------------------------------- by povilas at 2013-01-11T18:39:31Z @lsmith77, @Tobion, you mean, just move hash calculation to separate protected method, and when you want to change hashing you must extend BinaryFileResponse?
Why merge? If somebody wants to change it, he can simply overrite |
@@ -22,6 +22,7 @@ | |||
* @author Igor Wiedler <[email protected]> | |||
* @author Jordan Alliot <[email protected]> | |||
* @author Sergey Linnik <[email protected]> | |||
* @author Povilas Skruibis <[email protected]> |
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.
Really?
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.
@Tobion I thought its mandatory if you touch the file. If it's not, I can make PR to remove it.
@Tobion You are right, I read this too fast as I thought we decided to add this at some point. |
* 2.2: (22 commits) [Process] Fix regression introduced in #6620 / 880da01, fixes #7082 [HttpKernel] added a unit for the previous commit (closes #7025) [HttpFoundation] fixed, overwritten CONTENT_TYPE [BrowserKit] fixed test added in the previous merge (refs #7059) [FrameworkBundle] tweaked reference dumper command (see #7093) Remove unnecessary comment and change test name [Config] tweaked dumper to indent multi-line info [HttpKernel] added some tests for previous merge Fix REMOTE_ADDR for cached subrequests [FrameworkBundle] CSRF should be on by default [WebProfilerBundle] removed dependency on FrameworkBundle (closes #6949) [HttpKernel] added error display suppression when using the ErrorHandler (if not, errors are displayed twice, refs #6254) [HttpFoundation] tweaked previous merge [HttpFoundation] Added getter for httpMethodParameterOverride state Create validators.lv.xlf [Process] Warn user with a useful message when tmpfile() failed [BrowserKit] added a test to make sure HTTP authentication is preserved when submitting a form Remove array type hint from GetResponseForControllerResultEvent::setControllerResult() bumped Symfony version to 2.2.0-DEV Revert "merged branch povilas/issue_6101 (PR #6708)" ...
* 2.2: (22 commits) [Process] Fix regression introduced in symfony#6620 / 880da01, fixes symfony#7082 [HttpKernel] added a unit for the previous commit (closes symfony#7025) [HttpFoundation] fixed, overwritten CONTENT_TYPE [BrowserKit] fixed test added in the previous merge (refs symfony#7059) [FrameworkBundle] tweaked reference dumper command (see symfony#7093) Remove unnecessary comment and change test name [Config] tweaked dumper to indent multi-line info [HttpKernel] added some tests for previous merge Fix REMOTE_ADDR for cached subrequests [FrameworkBundle] CSRF should be on by default [WebProfilerBundle] removed dependency on FrameworkBundle (closes symfony#6949) [HttpKernel] added error display suppression when using the ErrorHandler (if not, errors are displayed twice, refs symfony#6254) [HttpFoundation] tweaked previous merge [HttpFoundation] Added getter for httpMethodParameterOverride state Create validators.lv.xlf [Process] Warn user with a useful message when tmpfile() failed [BrowserKit] added a test to make sure HTTP authentication is preserved when submitting a form Remove array type hint from GetResponseForControllerResultEvent::setControllerResult() bumped Symfony version to 2.2.0-DEV Revert "merged branch povilas/issue_6101 (PR symfony#6708)" ...
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Todo: -
Fixes the following tickets: #6101
License of the code: MIT
Documentation PR: -
This commit adds ability to change default hashing implementation by extending BinaryFileResponse.