You are here: Foswiki>Tasks Web>Item14366 (08 Apr 2017, GeorgeClark)Edit Attach

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

pencil
Priority: Urgent
Current State: Waiting for Release
Released In: 2.1.4
Target Release: patch
Applies To: Engine
Component: PlatformPerl
Branches: Release02x01 master
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.
 

ItemTemplate edit

Summary use CGI::Carp in bin scripts BEGIN block cannot be found via LocalLib.cfg override.
ReportedBy GeorgeClark
Codebase 2.1.3
SVN Range
AppliesTo Engine
Component PlatformPerl
Priority Urgent
CurrentState Waiting for Release
WaitingFor
Checkins distro:e7c23479e22c distro:8a9c3c4c43c8
TargetRelease patch
ReleasedIn 2.1.4
CheckinsOnBranches Release02x01 master
trunkCheckins
masterCheckins distro:8a9c3c4c43c8
ItemBranchCheckins
Release02x01Checkins distro:e7c23479e22c
Release02x00Checkins
Release01x01Checkins
Topic revision: r2 - 08 Apr 2017, GeorgeClark - This page was cached on 09 Apr 2017 - 00:11.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License