Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Closed
wants to merge 3 commits into from
Closed

[HttpFoundation] moved file hash calculation to own method #6708

wants to merge 3 commits into from

Conversation

povilas
Copy link
Contributor

@povilas povilas commented Jan 11, 2013

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.

@stloyd
Copy link
Contributor

stloyd commented Jan 11, 2013

IMO it's looks a like overkill...

@lsmith77
Copy link
Contributor

hmm yeah .. seems like something that could be done via inheritance ..

@Tobion
Copy link
Contributor

Tobion commented Jan 11, 2013

I agree, overriting the method is much simpler solution.

@jalliot
Copy link
Contributor

jalliot commented Jan 11, 2013

Besides the $autoetag variable is false by default so you have to explicitly enable this behavior...

@povilas
Copy link
Contributor Author

povilas commented Jan 11, 2013

@lsmith77, @Tobion, you mean, just move hash calculation to separate protected method, and when you want to change hashing you must extend BinaryFileResponse?

*
* @return string
*/
protected function calculateFileHash()
Copy link
Member

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.

Copy link
Contributor Author

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());
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

fabpot added a commit that referenced this pull request Feb 11, 2013
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?
@fabpot fabpot closed this Feb 11, 2013
@Tobion
Copy link
Contributor

Tobion commented Feb 11, 2013

Why merge? If somebody wants to change it, he can simply overrite setAutoETag. Adding extra methods for extensibility just increases the API that has to be maintained.

@@ -22,6 +22,7 @@
* @author Igor Wiedler <[email protected]>
* @author Jordan Alliot <[email protected]>
* @author Sergey Linnik <[email protected]>
* @author Povilas Skruibis <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

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

Really?

Copy link
Contributor Author

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.

@fabpot
Copy link
Member

fabpot commented Feb 11, 2013

@Tobion You are right, I read this too fast as I thought we decided to add this at some point.

fabpot added a commit that referenced this pull request Feb 11, 2013
This reverts commit b2bcbbb, reversing
changes made to c5fcf0d.
fabpot added a commit that referenced this pull request Feb 18, 2013
* 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)"
  ...
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull request Mar 25, 2018
* 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)"
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants