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.

[PATCH] ActiveSupport::Memoizable - flush_cache fails for methods ending in ?

#3138

Since the symbols passed to flush_cache are interpreted as part of a regex, passing a symbol ending in ? doesnt clear the cache for that method

foo?(a,b) <= memoized method
flush_cache(:foo?) <= does not flush the cache for foo? instead it flushs for foo

a workaround is to do flush_cache('foo\?') but it would be better if this worked as expected

Reported by twalpole · September 3rd, 2009 @ 07:43 PM

State: committed
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. John Pignata
    John Pignata
    • Tag set to 3, activesupport, memoization

    Added a quick fix and a test for this case.

    September 4th, 2009 @ 10:29 PM

  2. John Pignata
    John Pignata
    • Tag changed from 3, activesupport, memoization to activesupport, memoization

    September 4th, 2009 @ 10:30 PM

  3. John Pignata
    John Pignata
    • Tag changed from activesupport, memoization to activesupport, memoization, patch
    • Title changed from ActiveSupport::Memoizable - flush_cache fails for methods ending in ? to [PATCH] ActiveSupport::Memoizable - flush_cache fails for methods ending in ?

    September 18th, 2009 @ 04:12 AM

  4. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from activesupport, memoization, patch to activesupport, bugmash, memoization, patch

    September 25th, 2009 @ 12:35 PM

  5. Elad Meidar
    Elad Meidar
    • Tag changed from activesupport, bugmash, memoization, patch to activesupport, bugmash, bugmash-review, memoization, patch

    +1 verified on master and 2-3-stable, patch applies cleanly.

    As discussed on #railbridge some further tests for methods that end with ! as well could be nice, although not mandatory since ! is not a reserved regexp character.

    September 27th, 2009 @ 04:54 AM

  6. hsume2 (Henry)
    hsume2 (Henry)

    +1 patched applied cleanly on master and 2-3-stable

    September 27th, 2009 @ 04:56 AM

  7. sr.iniv.t
    sr.iniv.t

    +1 verified.

    The patch applies cleanly on master and 2-3-stable and all tests pass.

    September 27th, 2009 @ 07:05 AM

  8. Kieran P
    Kieran P

    +1 verified. Though perhaps a Regexp.escape might be more appropriate?

    September 27th, 2009 @ 07:09 AM

  9. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from activesupport, bugmash, bugmash-review, memoization, patch to activesupport, bugmash-review, memoization, patch

    September 27th, 2009 @ 12:35 PM

  10. John Pignata
    John Pignata

    Kieran - The reason I couldn't use Regexp.escape is that it causes tests for the unmemoize_all method to fail as it passes .* to flush_cache.

    September 27th, 2009 @ 02:33 PM

  11. Repository
    Repository
    • State changed from new to committed

    (from [d48ebeade2d907573e3fb086495b57b10115066c]) Escaping symbol passed into Memoizable's flush_cache for query methods to allow them to be cleared

    Signed-off-by: Michael Koziarski michael@koziarski.com

    [#3138 state:committed] http://github.com/rails/rails/commit/d48ebeade2d907573e3fb086495b57...

    September 28th, 2009 @ 03:29 AM

  12. Rizwan Reza
    Rizwan Reza
    • Tag changed from activesupport, bugmash-review, memoization, patch to activesupport, memoization, patch

    May 15th, 2010 @ 06:42 PM