This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make Storable load even with %INC modified
authorFather Chrysostomos <sprout@cpan.org>
Thu, 3 Nov 2011 00:04:33 +0000 (17:04 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 3 Nov 2011 00:04:33 +0000 (17:04 -0700)
Modified to stop Log::Agent from loading, that is.

There‚Äôs at least one CPAN module that does it.  While that module
could be blamed, Storable used to be more robust in this area
before the AutoLoader extirpation, and there is nothing wrong with
robustness.

MANIFEST
dist/Storable/Storable.pm
dist/Storable/t/robust.t [new file with mode: 0644]

index f4a5644..159786e 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -3425,6 +3425,7 @@ dist/Storable/t/overload.t                See if Storable works
 dist/Storable/t/recurse.t              See if Storable works
 dist/Storable/t/restrict.t             See if Storable works
 dist/Storable/t/retrieve.t             See if Storable works
+dist/Storable/t/robust.t               See if it survives mangled %INC
 dist/Storable/t/sig_die.t              See if Storable works
 dist/Storable/t/st-dump.pl             See if Storable works
 dist/Storable/t/store.t                        See if Storable works
index 3e995c3..561f00e 100644 (file)
@@ -21,7 +21,7 @@ package Storable; @ISA = qw(Exporter);
 
 use vars qw($canonical $forgive_me $VERSION);
 
-$VERSION = '2.32';
+$VERSION = '2.33';
 
 BEGIN {
     if (eval { local $SIG{__DIE__}; require Log::Agent; 1 }) {
@@ -31,13 +31,14 @@ BEGIN {
     # Use of Log::Agent is optional. If it hasn't imported these subs then
     # provide a fallback implementation.
     #
-    else {
+    if (!exists &logcroak) {
         require Carp;
-
         *logcroak = sub {
             Carp::croak(@_);
         };
-
+    }
+    if (!exists &logcarp) {
+       require Carp;
         *logcarp = sub {
           Carp::carp(@_);
         };
diff --git a/dist/Storable/t/robust.t b/dist/Storable/t/robust.t
new file mode 100644 (file)
index 0000000..27f5fc0
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+
+# This test script checks that Storable will load properly if someone
+# is incorrectly messing with %INC to hide Log::Agent.  No, no-one should
+# really be doing this, but, then, it *used* to work!
+
+use Test::More;
+plan tests => 1;
+
+$INC{'Log/Agent.pm'} = '#ignore#';
+require Storable;
+pass;