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.

ActiveSupport::Deprecation::DeprecationProxy objects wrap nil and false

#5177

ActiveSupport::Deprecation::DeprecationProxy objects aren't used much in Rails, but where they are, nothing is done to ensure that they don't wrap false or nil. This can lead to perplexing and nasty little bugs, where you do a test on an object you expect to always be falsy, and it returns true. Observe the following case:

>> proxy = ActiveSupport::Deprecation::DeprecatedObjectProxy(nil, "message")
=> nil
>> proxy.nil?
=> true
>> !!proxy
=> true

This, to say the least, is unexpected behavior. I'm of the opinion that these invisible proxy objects might be more trouble than they're worth, but rather than getting rid of them altogether, I'd like to propose that we just don't let them wrap nil or false. It seems we should probably favor not breaking built-in language functionality over deprecation warnings.

I'm attaching a patch against Rails 3, but this issue is even more nefarious in Rails 2.3.x, because ActiveSupport::Deprecation::DeprecatedObjectProxy is used in render_partial. I'll also prepare a backport fix and post it here.

Reported by Leigh Caplan · July 22nd, 2010 @ 01:30 AM

State: committed
Milestone: 3.0.2
Assigned to: Aaron Patterson Aaron Patterson
Importance: Low

Activity

  1. Leigh Caplan
  2. Aaron Patterson
    Aaron Patterson
    • State changed from new to committed
    • Milestone cleared.
    • Importance changed from to Low

    I've committed these.

    July 26th, 2010 @ 05:55 PM

  3. Jeremy Kemper