Item14366: use CGI::Carp
in bin scripts BEGIN block cannot be found via LocalLib.cfg override.
Priority: Urgent
Current State: Closed
Released In: 2.1.4
Target Release: patch
- The setlib happens after CGI::Carp is referenced
- The use statement needs to be done with a require.
The following patch appears to resolve the issue:
diff --git a/core/bin/view b/core/bin/view
index 5ddd6f0..24e00d2 100755
--- a/core/bin/view
+++ b/core/bin/view
@@ -6,9 +6,15 @@ use warnings;
use File::Spec;
BEGIN {
+ my ( $volume, $binDir, $action ) = File::Spec->splitpath(__FILE__);
+ my $setlib = File::Spec->catpath( $volume, $binDir, 'setlib.cfg' );
+ @INC = ( '.', grep { $_ ne '.' } @INC ) unless $binDir;
+ require $setlib;
+
if ( defined $ENV{GATEWAY_INTERFACE} || defined $ENV{MOD_PERL} ) {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CGI';
- use CGI::Carp qw(fatalsToBrowser);
+ require CGI::Carp;
+ CGI::Carp->import(qw(fatalsToBrowser));
$SIG{__DIE__} = \&CGI::Carp::confess;
}
else {
@@ -16,10 +22,6 @@ BEGIN {
require Carp;
$SIG{__DIE__} = \&Carp::confess;
}
- my ( $volume, $binDir, $action ) = File::Spec->splitpath(__FILE__);
- my $setlib = File::Spec->catpath( $volume, $binDir, 'setlib.cfg' );
- @INC = ( '.', grep { $_ ne '.' } @INC ) unless $binDir;
- require $setlib;
$ENV{FOSWIKI_ACTION} = 'view';
}
--
GeorgeClark - 02 Apr 2017
Marking this urgent because recent Perl versions no longer ship with CGI or CGI::Carp.