This project is archived and is in readonly mode.

#5177 ✓committed
Leigh Caplan

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

Reported by Leigh Caplan | July 22nd, 2010 @ 01:30 AM | in 3.0.2

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.

Comments and changes to this ticket

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>

Pages