Skip Menu |

This queue is for tickets about the Object-Accessor CPAN distribution.

Report information
The Basics
Id: 68154
Status: resolved
Worked: 40 min
Priority: 0/
Queue: Object-Accessor

People
Owner: BINGOS [...] cpan.org
Requestors: IKEGAMI [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Avoid use of deprecated exists($a[$i])
Object::Accessor uses L<perlfunc/exists> on array elements, and that has been deprecated since at least 5.12.0. I think avoiding it is very simple: --- a/lib/Object/Accessor.pm +++ b/lib/Object/Accessor.pm @@ -513,7 +513,7 @@ sub ___autoload { } ### need to check the value? - if( exists $self->{$method}->[ALLOW] ) { + if( defined $self->{$method}->[ALLOW] ) { ### double assignment due to 'used only once' warnings local $Params::Check::VERBOSE = 0; @@ -576,7 +576,7 @@ sub ___set { my $method = shift or return; ### you didn't give us a value to set! - exists $_[0] or return; + @_ or return; my $val = shift; ### if there's more arguments than $self, then
Hi, Good catch! I've applied and released version 0.40 to CPAN. Many thanks.
I forgot to mention there's also a use of it t/05_Object-Accessor-callback.t, sorry.
On Thu May 12 17:24:46 2011, ikegami wrote: Show quoted text
> I forgot to mention there's also a use of it > t/05_Object-Accessor-callback.t, sorry. >
Perhaps the fix is scalar @$val ? is( $val->[0], $SetVal, " Attempted to set $SetVal" ) - : ok( ! exists $val->[0], + : ok( ! @$val, " This was a GET request" );
Thanks!
I don't know how I missed it the first time around, but there is another deprecated use of exists on array elements. sub ls_allow { my $self = shift; my $key = shift or return; return exists $self->{$key}->[ALLOW] ? $self->{$key}->[ALLOW] : sub { 1 }; } (I'm working on adding a deprecated warning to exists($a[0]) and delete($a[0]).)
All the issues raised by this ticket were resolved with 0.42 Many thanks.