Skip to content

[HttpFoundation] Fix isNotModified determination logic #40545

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

Conversation

ol0lll
Copy link
Contributor

@ol0lll ol0lll commented Mar 22, 2021

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #37948
License MIT
Doc PR symfony/symfony-docs#...

Use weak comparison for etags; Only do if-modified-since when no if-none-match header is present.
See #37948 (comment)

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@ol0lll ol0lll changed the base branch from 5.x to 4.4 March 22, 2021 15:48
@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Mar 22, 2021
@nicolas-grekas
Copy link
Member

This breaks some existing tests, please have a look, and add more if it makes sense.

@ol0lll ol0lll force-pushed the fix-isNotModified-determination-logic branch from b9f64b4 to 80f278f Compare March 23, 2021 16:50
@ol0lll ol0lll force-pushed the fix-isNotModified-determination-logic branch 2 times, most recently from 25696a3 to 352b1f0 Compare March 25, 2021 16:42
@ol0lll ol0lll closed this Mar 25, 2021
@ol0lll ol0lll reopened this Mar 25, 2021
@ol0lll
Copy link
Contributor Author

ol0lll commented Mar 26, 2021

Tests are running fine on local machine, travis seems to be on correct tag after closing / re-opening the pr. I honestly do not know why the test fails on travis. Any ideas?

@xabbuh
Copy link
Member

xabbuh commented Mar 26, 2021

In the composer.json file of the HttpKernel component you need to update the HttpFoundation constraints like this:

"symfony/http-foundation": "^4.4.21|^5.2.6"

@@ -20,7 +20,7 @@
"symfony/error-handler": "^4.4",
"symfony/event-dispatcher": "^4.4",
"symfony/http-client-contracts": "^1.1|^2",
"symfony/http-foundation": "^4.4|^5.0",
"symfony/http-foundation": "^4.4.21|^5.2.6",
Copy link
Member

Choose a reason for hiding this comment

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

should be bumped to ^4.4.22|^5.2.7 now that 4.4.21 and5.2.6 have been released

@ol0lll ol0lll force-pushed the fix-isNotModified-determination-logic branch from befd41e to 3befea3 Compare March 30, 2021 15:04
@Nyholm
Copy link
Member

Nyholm commented Mar 31, 2021

Thank you.

Travis is failing and when I reviewed the output I suspect that the failure is related to this PR. Can you confirm?

@ol0lll
Copy link
Contributor Author

ol0lll commented Apr 12, 2021

Thank you.

Travis is failing and when I reviewed the output I suspect that the failure is related to this PR. Can you confirm?

A friend of mine did ask this on slack and this was the outcome:

alexpott 30 Mar at 16:49
@xabbuh @nicolasgrekas I’m trying to help a friend with a Symfony PR - #40545 - the problem is that HttpKernel tests are failing because HttpFoundation is changing. The PR passes locally when running the tests with both components patches. I’ve looked at the .travis.yml file and I’ve tried to work out how it determines to use components that have changed as part of MR as dependencies but I can’t see how. I feel like I missing something obvious

xabbuh 13 days ago
in this case, the deps=high job is allowed to fail

xabbuh 13 days ago
deps=low passes that’s important

xabbuh 13 days ago
the other job will pass once the branch is merged up

alexpott 13 days ago
Ah thanks… and I was about to ask the question that @nicolasgrekas just answered on the PR - thanks to both you!

xabbuh 13 days ago
ah indeed, I missed that we had new releases after the latest PR update

@TheNewSound
Copy link

TheNewSound commented Apr 12, 2021

uses wrong header tag, if_none_match should be If-None-Match

EDIT: shouldn't matter since _ are replaced by - and capital letters always to lowercase.

@ol0lll ol0lll force-pushed the fix-isNotModified-determination-logic branch from f35615d to 6b2a7f4 Compare April 12, 2021 17:58
@TheNewSound

This comment has been minimized.

@maxhelias
Copy link
Contributor

Needs a rebase to fix conflicts

@ol0lll ol0lll force-pushed the fix-isNotModified-determination-logic branch from 6b2a7f4 to 07d51e2 Compare May 17, 2021 12:14
@PF4Public
Copy link
Contributor

This should probably resolve sensiolabs/SensioFrameworkExtraBundle#513 in a better way than simply adding weak ETags!

@fabpot
Copy link
Member

fabpot commented Aug 26, 2021

Thank you @ol0lll.

fabpot added a commit that referenced this pull request Aug 26, 2021
…0lll)

This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[HttpFoundation] Fix isNotModified determination logic

| Q             | A
| ------------- | ---
| Branch?       | 4.4  <!-- see below -->
| 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 #37948 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Use weak comparison for etags; Only do if-modified-since when no if-none-match header is present.
See #37948 (comment)

<!--
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
-->

Commits
-------

77bd21a [HttpFoundation] Fix isNotModified determination logic
@fabpot fabpot closed this Aug 26, 2021
This was referenced Aug 30, 2021
@chrfritsch chrfritsch deleted the fix-isNotModified-determination-logic branch December 6, 2021 11:56
public function testIsNotModifiedWeakEtag()
{
$etag = 'randomly_generated_etag';
$weakEtag = 'W/randomly_generated_etag';
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for noticing.
Could you submit a PR fixing this with a small explanation?

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.

[HttpFoundation] ETag for If-None-Match comparison
9 participants