Skip to content

Fix #105 #119

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 2 commits into from
Jul 31, 2014
Merged

Fix #105 #119

merged 2 commits into from
Jul 31, 2014

Conversation

ddeboer
Copy link
Member

@ddeboer ddeboer commented Jul 30, 2014

  • configured tags can access request.attributes with simple expression vars (id)
  • response is no longer available as a value for expressions; but there’s no use case
    for that anyway
  • update docs

@@ -15,7 +15,6 @@
use FOS\HttpCacheBundle\Configuration\Tag;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused.

* configured tags can access request.attributes with simple expression vars (id)
* response is no longer available as a value for expressions; but there’s no use case
  for that anyway
* update docs
@ddeboer
Copy link
Member Author

ddeboer commented Jul 30, 2014

Before we merge this: is there a mismatch between expressions in TagSubscriber and tag_expressions in Configuration? Or is this intentional?

@dbu
Copy link
Contributor

dbu commented Jul 31, 2014

+1 for the PR

for the naming: this is remapped in FOSHttpCacheExtension::loadTagRules. so it works correctly atm. not sure what makes sense - maybe go for expression everywhere, to be consistent with the field in the @Tag annotation?

@ddeboer
Copy link
Member Author

ddeboer commented Jul 31, 2014

I’m okay with tag_expressions as it’s a bit more explicit. Just added a functional test here to validate the behaviour. This can be merged when green.

dbu added a commit that referenced this pull request Jul 31, 2014
@dbu dbu merged commit c166470 into master Jul 31, 2014
@dbu dbu deleted the fix-105 branch July 31, 2014 07:21
@dbu
Copy link
Contributor

dbu commented Jul 31, 2014

green and merged :-)

KernelEvents::RESPONSE => 'onKernelResponse'
return $this->expressionLanguage->evaluate(
$expression,
$request->attributes->all()
Copy link
Member

Choose a reason for hiding this comment

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

this does not have the Request itself anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

i think it also did not have the request previously, no?

Copy link
Member

Choose a reason for hiding this comment

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

depends. On line 81 it was passed. On line 122 it was not (and this call looks invalid by passing a Request in an argument expecting an array)

Copy link
Member Author

Choose a reason for hiding this comment

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

@stof What do you mean exactly? evaluateTag(string $expression, Request $request) wraps a call to $expressionLanguage->evaluate(string $expression, array $values). As far as I can see evaluateTag is called twice, both times with a Request object:

https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/blob/master/EventListener/TagSubscriber.php#L80
https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/blob/master/EventListener/TagSubscriber.php#L127

Copy link
Member

Choose a reason for hiding this comment

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

@ddeboer the comment to which I replied was refering to the previous code

Copy link
Member

Choose a reason for hiding this comment

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

@ddeboer well, SensioFRameworkExtraBundle is inconsistent. For @Security, you get more stuff, like the request.

@dbu the behavior for @Security is that known params always win. this way, you always know that request is the Request object. If you have a request attribute with the same name, you can always get it from the Request object.

Copy link
Contributor

Choose a reason for hiding this comment

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

what if we just add the request for advanced users, mention it in the doc but do not have any examples using the request, to keep them simple? the strategy to overwrite a possible request attribute with the Request means that there would be a BC break if we would add this later.

Copy link
Member Author

Choose a reason for hiding this comment

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

@stof Good point, and your use case makes sense. So let’s just give access to Request, too (while keeping easy access to request attributes; after all, that is what this PR was for). @dbu Can you create a PR for adding Request? To me this is no blocker for 1.0, as it won’t break BC.

Copy link
Member Author

Choose a reason for hiding this comment

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

@dbu Ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

see #144

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.

3 participants