This project is archived and is in readonly mode.
Action cache filter code incorrectly renders nil response body if response is non-cacheable
Reported by Cheah Chu Yeow | February 27th, 2011 @ 03:11 PM
Best explained with an example - consider the simple controller below:
class ActionCachingTestController < ActionController::Base
caches_action :four_oh_four
def four_oh_four
render :text => "404'd!", :status => 404
end
end
The four_oh_four
action returns a HTTP 404
response, which is non-cacheable. The Action cache filter, however,
has faulty code that causes the response to be nil (basically an
empty page is returned).
I've attached a patch that fixes this by continuing to render the response body in cases where an action is non-cacheable.
Tested against Rails master @ f3e9cbc69.
Comments and changes to this ticket
-
Jeff Kreeftmeijer February 28th, 2011 @ 04:21 PM
- State changed from new to verified
- Assigned user set to Santiago Pastorino
- Importance changed from to Low
Verified. Patch applies to master cleanly and tests pass. Test is good and fails without the fix. :)
We might want to push this one to stable too. Santiago, what do you think? :)
-
Josh Kalderimis February 28th, 2011 @ 04:48 PM
- Tag changed from actionpack, caches_action, caching, patch to actionpack, patch
+1 for master and stable, seems like a good correction to both!
-
Lenary February 28th, 2011 @ 10:47 PM
+1 applies cleanly to 3-0-stable and to master cleanly on my machine, and doesn't even break anything!
-
Repository March 2nd, 2011 @ 03:14 PM
- State changed from verified to committed
(from [2ee55557440a644453482a678e4ff08a4b5ebd3e]) Fix Action caching bug where an action that has a non-cacheable response always renders a nil response body. It now correctly renders the response body.
Note that only GET and HTTP 200 responses can be cached.
[#6480 state:committed]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/2ee55557440a644453482a678e4ff... -
Repository March 2nd, 2011 @ 03:17 PM
(from [beec6c8b2abfd3286bd7c0a1c7ecb04686af6448]) Fix Action caching bug where an action that has a non-cacheable response always renders a nil response body. It now correctly renders the response body.
Note that only GET and HTTP 200 responses can be cached.
[#6480 state:committed]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
https://github.com/rails/rails/commit/beec6c8b2abfd3286bd7c0a1c7ecb...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 5773 ActionController crashes when trying to render head 406 with caches_action Duplicate of #6480
- 6480 Action cache filter code incorrectly renders nil response body if response is non-cacheable [#6480 state:committed]
- 6480 Action cache filter code incorrectly renders nil response body if response is non-cacheable [#6480 state:committed]