Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

cache_sweeper yields blank output

#3914

In rails 3, adding a cache_sweeper to the controller makes the pages output blank

Reported by Aaron · February 9th, 2010 @ 07:00 PM

State: resolved
Milestone: none
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Aaron
    Aaron
    • Tag changed from cache_sweeper sweeper to cache, cache_sweeper, sweeper

    February 9th, 2010 @ 07:16 PM

  2. Si
    Si

    I'm seeing this too. Instead of running any code in the method, I get the following plus a blank screen:

    Completed 200 OK in 717ms

    I'm running:

    ruby 1.9.2dev (2010-04-02 trunk 27189) [x86_64-darwin10]
    Rails 3.0.0.beta2

    April 4th, 2010 @ 06:56 PM

  3. Si
    Si

    Looks like ActionController::Caching::Sweeper doesn't return true as a default when callbacks aren't run (!controller.perform_caching).

    Including a patch.

    April 4th, 2010 @ 10:50 PM

  4. Si
    Si
    • Tag changed from cache, cache_sweeper, sweeper to cache, cache_sweeper, patch, sweeper

    April 4th, 2010 @ 10:52 PM

  5. aaronchi
    aaronchi
    • Tag changed from cache, cache_sweeper, patch, sweeper to cache, cache_sweeper, patch, rails3, sweeper

    April 5th, 2010 @ 03:12 AM

  6. Si
    Si

    Now I'm pushing up to staging I see that the before filter will need to return true in all cases. This is because the sweeper filter aspect is really implementation detail, and sweepers shouldn't prevent actions running like regular filters can.

    I've updated the patch.

    May 1st, 2010 @ 08:36 AM

  7. Neeraj Singh
    Neeraj Singh

    I am not able to simulate this problem in rails edge. Could you try to simulate this problem with rails edge and see if it is still an issue.

    May 1st, 2010 @ 03:15 PM

  8. kevmoo
    kevmoo

    Reproduced on edge Ref: 6d7f2790cdb6cb232850, May 6, 2010

    class MainController < ApplicationController
    cache_sweeper :app_sweeper

    def index end end

    class AppSweeper < ActionController::Caching::Sweeper
    end

    May 6th, 2010 @ 11:27 PM

  9. kevmoo
    kevmoo

    Verified Si's patch 'return_true_for_non_caching_sweeper_filter.diff' fixes the issue.

    NO clue if this breaks anything else, but my page is loading.

    May 6th, 2010 @ 11:31 PM

  10. kevmoo
    kevmoo

    ...and I take that back. I added an after_save to the sweeper and we're back to the original issue -> blank output

    May 6th, 2010 @ 11:48 PM

  11. Neeraj Singh
    Neeraj Singh

    Attached is a patch with test. I was not really sure how to go about testing this one. So any feedback on testing strategy is welcome.

    May 7th, 2010 @ 06:23 AM

  12. Si
    Si

    Hi Kevmoo, I updated that patch but the fix is the same in Neeraj's diff. Can you try that?

    May 7th, 2010 @ 08:24 AM

  13. Dan Pickett
    Dan Pickett
    • Tag changed from cache, cache_sweeper, patch, rails3, sweeper to bugmash, cache, cache_sweeper, patch, rails3, sweeper

    May 9th, 2010 @ 06:48 PM

  14. marian (at bitflut)
    marian (at bitflut)
    • Tag changed from bugmash, cache, cache_sweeper, patch, rails3, sweeper to rails 3.0.0.beta4, bugmash, cache, cache_sweeper, patch, rails3, sweeper

    Still there in rails 3 beta 4

    June 8th, 2010 @ 09:23 PM

  15. José Valim
    José Valim

    Applied, but still need better tests.

    June 8th, 2010 @ 10:20 PM

  16. Repository
    Repository
    • State changed from new to open

    June 8th, 2010 @ 10:21 PM

  17. Neeraj Singh
    Neeraj Singh
    • Assigned user set to José Valim

    Attaching improvised test.

    June 9th, 2010 @ 04:28 AM

  18. Repository
    Repository
    • State changed from open to resolved

    June 9th, 2010 @ 09:07 AM