Skip Menu |
 

This queue is for tickets about the Cache-Cache CPAN distribution.

Report information
The Basics
Id: 79769
Status: resolved
Priority: 0/
Queue: Cache-Cache

People
Owner: Nobody in particular
Requestors: rjbs [...] cpan.org
Cc:
AdminCc:

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

Attachments
0001-Check-the-value-of-instead-of-using-defined.patch



Subject: checks "defined @$" instead of "defined $@"
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 730
Download (untitled) / with headers
text/plain 730b
Well, is this critical? I'm not sure. I thought it was only cosmetic, because it was raising a "you're using defined ARRAY" warning, which is just a warnings. But when I found the error, it was checking "defined @$" when it really wanted to test $@ to see whether an eval completed successfully. This is wrong not only because of the sigil transposition, but also because $@ is set to an empty (defined) string on no-error, meaning that the test doesn't work even with the transposition fixed. _test_sixteen in Cache::CacheTester should instead end like this: ( $ok ) ? $self->ok( ) : $self->not_ok( "couldn't create autopurge cache" ); I couldn't provide a pull request because I didn't see a repo. :-) -- rjbs
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: API
Content-Type: multipart/mixed; boundary="----------=_1406973150-17121-10"
Message-ID: <rt-4.0.18-17121-1406973150-1699.0-0-0 [...] rt.cpan.org>
Message-ID: <rt-4.0.18-17121-1406973150-210.79769-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
From: fraserbn [...] gmail.com
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 924
Download (untitled) / with headers
text/plain 924b
On Thu Sep 20 15:36:58 2012, RJBS wrote: Show quoted text
> Well, is this critical? I'm not sure. > > I thought it was only cosmetic, because it was raising a "you're using > defined ARRAY" warning, > which is just a warnings. > > But when I found the error, it was checking "defined @$" when it > really wanted to test $@ to see > whether an eval completed successfully. This is wrong not only > because of the sigil > transposition, but also because $@ is set to an empty (defined) string > on no-error, meaning that > the test doesn't work even with the transposition fixed. > > _test_sixteen in Cache::CacheTester should instead end like this: > > ( $ok ) ? > $self->ok( ) : $self->not_ok( "couldn't create autopurge cache" ); > > I couldn't provide a pull request because I didn't see a repo. :-)
..it's doubly critical now, since defined(@array) is an error in 5.21. The attached patch should fix both this ticket and #87244
MIME-Version: 1.0
Subject: 0001-Check-the-value-of-instead-of-using-defined.patch
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Type: application/octet-stream; name="0001-Check-the-value-of-instead-of-using-defined.patch"
Content-Disposition: inline; filename="0001-Check-the-value-of-instead-of-using-defined.patch"
Content-Transfer-Encoding: base64
Content-Length: 1187
From 4f8778be9343d2c3e8e43e4666a1845ea35e8667 Mon Sep 17 00:00:00 2001 From: Brian Fraser <fraserbn@gmail.com> Date: Sat, 2 Aug 2014 11:48:29 +0200 Subject: [PATCH] Check the value of $@ instead of using defined(@$) This was two bugs in one. First one is simple; due to a typo, the module was checking @$ instead of $@; in 5.21, defined(@arr) is an exception, so this started blowing up. The second is more of a thinko -- defined($@) after an eval will almost always be true, regardless of what happened inside the eval! $ perl -E 'eval {1}; say defined $@; eval {die}; say defined $@' 1 1 So the correct thing to do is to check for the truthfulness of $@, not the definedness. --- lib/Cache/CacheTester.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cache/CacheTester.pm b/lib/Cache/CacheTester.pm index 8f64577..b695863 100644 --- a/lib/Cache/CacheTester.pm +++ b/lib/Cache/CacheTester.pm @@ -559,7 +559,7 @@ sub _test_sixteen $cache = $cache->new( { 'auto_purge_interval' => $expires_in } ); }; - ( not defined @$ ) ? + ( not $@ ) ? $self->ok( ) : $self->not_ok( "couldn't create autopurge cache" ); } -- 1.7.12.4 (Apple Git-37)
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-29683-1406986926-572.79769-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 77
Cache::Cache is ancient and no longer maintained. Recommend switching to CHI.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-28025-1410962519-607.79769-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 23
Fixed in 1.07 -- rjbs


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.