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.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

ActiveSupport::Cache::FileStore: undefined method `ord' for nil:NilClass

#5850

undefined method ord' for nil:NilClass

This issue raise in rails 3.0.0 and rails 3.0.1, when I using file_store for cache_store.

 config.action_controller.cache_store = ActiveSupport::Cache::FileStore.new(Rails.root.join("tmp", "cache").to_s)

My fix:

  module ActiveSupport
    module Cache
      class FileStore < Store

      private

        # Translate a file path into a key.
        def file_path_key(path)
          fname = path[cache_path.size, path.size].split(File::SEPARATOR, 4).last
          fname.gsub(UNESCAPE_FILENAME_CHARS){|match| [match.delete('%')].pack('H*') }
        end
      end
    end
  end

Reported by Igor Galeta · October 21st, 2010 @ 12:49 PM

State: committed
Milestone: 3.0.2
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: Low

Activity

  1. Aditya Sanghi
    Aditya Sanghi
    • Importance changed from to Low

    Can you please submit a failing test and a patch as per the contributor's guide?

    It wasn't very clear what the scenario in which error happens or steps to reproduce the error.

    October 21st, 2010 @ 01:53 PM

  2. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Milestone set to 3.0.2
    • Assigned user set to Santiago Pastorino

    Igor can you provide a patch following http://rails.lighthouseapp.com/projects/8994/sending-patches or at least a failing test case?.
    Thanks.

    October 21st, 2010 @ 02:46 PM

  3. Denis Odorcic
    Denis Odorcic

    Attached is a patch and failing test.

    The issue was that with FileStore, the key is the filename, which was being escaped properly, but not unescaped. This only presents itself when the cache is FileStore, the key contains characters that get escaped, and expire_fragment is called with a Regular expression.

    The fix that Igor provided above does fix the issue, however the escaping and unescaping is essentially the same method used by CGI, so my patch uses that instead.
    If you think it should go back to how it was and just use Igor's fix, that's fine.

    October 23rd, 2010 @ 07:04 AM

  4. Denis Odorcic
    Denis Odorcic
    • Tag changed from activesupport, caching, file_store, rails3.0.0, rails3.0.1 to activesupport, caching, file_store, patch, rails3.0.0, rails3.0.1

    October 23rd, 2010 @ 09:54 PM

  5. Santiago Pastorino
    Santiago Pastorino

    Please use Rack::Utils.escape and unscape instead of CGI one.

    November 7th, 2010 @ 07:02 PM

  6. Denis Odorcic
    Denis Odorcic

    I've attached an updated patch using Rack::Utils. Thanks!

    November 7th, 2010 @ 08:02 PM

  7. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to verified

    November 7th, 2010 @ 08:12 PM

  8. Repository
    Repository
    • State changed from verified to committed

    (from [c452d734f202fef3560173cd10701be8ff1a057b]) Fix FileStore cache incorrectly regenerating its key from a pathname when a regexp is used in expire_fragment

    [#5850 ActiveSupport::Cache::FileStore: undefined method `ord' for nil:NilClass state:committed]

    Signed-off-by: Santiago Pastorino santiago@wyeworks.com
    https://github.com/rails/rails/commit/c452d734f202fef3560173cd10701...

    November 7th, 2010 @ 10:03 PM

  9. Repository
    Repository

    (from [ad2c0bdb9b94c79553e76f6b2db6fb23ccff6a97]) Fix FileStore cache incorrectly regenerating its key from a pathname when a regexp is used in expire_fragment

    [#5850 ActiveSupport::Cache::FileStore: undefined method `ord' for nil:NilClass state:committed]

    Signed-off-by: Santiago Pastorino santiago@wyeworks.com
    https://github.com/rails/rails/commit/ad2c0bdb9b94c79553e76f6b2db6f...

    November 7th, 2010 @ 10:03 PM