You are here: Foswiki>Tasks Web>Item14366 (31 Jan 2018, GeorgeClark)Edit Attach

Item14366: use CGI::Carp in bin scripts BEGIN block cannot be found via LocalLib.cfg override.

pencil
Priority: Urgent
Current State: Closed
Released In: 2.1.4
Target Release: patch
Applies To: Engine
Component: PlatformPerl
Branches: Release02x01 master Item14288 Item14380 Item14537
Reported By: GeorgeClark
Waiting For:
Last Change By: GeorgeClark
  • 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.
 
Topic revision: r8 - 31 Jan 2018, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy