Skip to content

Commit 52ae42d

Browse files
committed
Reduce priority for "NotModified" event listener
When the @ReplaceWithNotModifiedResponse annotation is used in combination with the @Cache annotation from SensioFrameworkExtraBundle, we need to make sure that \Webfactory\HttpCacheBundle\NotModified\EventListener is run *after* \Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener. The reason for this is that the "NotModified" listener will short-circuit the controller by replacing it with a no-op callback when a 304 response can be sent. This callback makes it impossible for the ControllerListener to parse annotations, since there is no longer a controller associated to the request. So we might get a 304 response, but that might be neither public not have the (s-)maxage settings as configured by annotations. So, to be independent of bundle registration order, we need to use a lower event listener priority. The downside is that now probably the default ParamConverter listeners will unneccessarily be executed. Given the current priorities in Symfony's FrameworkBundle and the SensioFrameworkExtra bundle, there is no way of getting "between" things.
1 parent e8903e8 commit 52ae42d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

NotModified/services.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<service class="Webfactory\HttpCacheBundle\NotModified\EventListener" public="true">
88
<argument type="service" id="annotation_reader" />
99
<argument type="service" id="service_container" />
10-
<tag name="kernel.event_listener" event="kernel.controller" />
10+
<tag name="kernel.event_listener" event="kernel.controller" priority="-200" />
1111
<tag name="kernel.event_listener" event="kernel.response" />
1212
</service>
1313
</services>

0 commit comments

Comments
 (0)