Skip to content

Commit

Permalink
Item14366: Reorder initialization to allow local CGI::Carp
Browse files Browse the repository at this point in the history
Latest perl does not ship with CGI or CGI::Carp.  By using a "use"
statement in the BEGIN block, it's not possible to provide this module
via setlib path overide.  Change to a "require" and reorder
initialization to call setlib before setting up CGI::Carp
  • Loading branch information
gac410 committed Apr 8, 2017
1 parent b31b259 commit e7c2347
Show file tree
Hide file tree
Showing 34 changed files with 247 additions and 177 deletions.
14 changes: 8 additions & 6 deletions CompareRevisionsAddOn/bin/compare
Expand Up @@ -6,20 +6,22 @@ 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 {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
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;
$action =~ s/\..*$//; # Remove eventual file extension
$ENV{FOSWIKI_ACTION} = $action;
}
Expand All @@ -30,7 +32,7 @@ $Foswiki::engine->run();
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2014 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Expand Down
14 changes: 8 additions & 6 deletions CompareRevisionsAddOn/bin/compareauth
Expand Up @@ -6,20 +6,22 @@ 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 {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
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;
$action =~ s/\..*$//; # Remove eventual file extension
$ENV{FOSWIKI_ACTION} = $action;
}
Expand All @@ -30,7 +32,7 @@ $Foswiki::engine->run();
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2014 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Expand Down
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1421599902" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1491685944" format="1.1" version="1"}%
%META:TOPICPARENT{name="CompareRevisionsAddOn"}%

---+ !CompareRevisionsAddOn Plugin
Expand Down Expand Up @@ -32,6 +32,7 @@ Test: <nop>CompareRevisionsAddOnPlugin is %IF{"context CompareRevisionsAddOnPlug
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 08 Apr 2017 (1.115) | Foswikitask:Item14366: Reorder initialization to allow local CGI::Carp. |
| 01 May 2014 (1.112) | Foswikitask:Item12407: Don't decode entities during comparson. Convert to simple decimal version. |
| 10 Feb 2014 | Foswikitask:Item12741: Formatting parameters not passed on the referenced scripts |
| 23 Oct 2013 (1.1.11) | Foswikitask:Item12423: fix double encoding in header on UTF-8 sites |
Expand Down
Expand Up @@ -2,12 +2,12 @@ package Foswiki::Contrib::CompareRevisionsAddOn;
use strict;

# Also update CompareRevisionsAddOnPlugin
our $VERSION = '1.114';
our $VERSION = '1.115';

# This is a free-form string you can use to "name" your own plugin version.
# It is *not* used by the build automation tools, but is reported as part
# of the version number in PLUGINDESCRIPTIONS. Keep in sync with $VERSION
our $RELEASE = '1.114';
our $RELEASE = '08 Apr 2017';

our $SHORTDESCRIPTION =
'Compares two revisions of a document. In contrast to normal _rdiff_, the comparison is done with the rendered HTML output.';
Expand All @@ -16,7 +16,7 @@ our $SHORTDESCRIPTION =
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2015 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2008-2017 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Expand Down
12 changes: 7 additions & 5 deletions ConfigurePlugin/bin/configure
Expand Up @@ -6,20 +6,22 @@ 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 {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
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;
$action =~ s/\..*$//; # Remove eventual file extension
$ENV{FOSWIKI_ACTION} = $action;
}
Expand Down
5 changes: 3 additions & 2 deletions ConfigurePlugin/data/System/ConfigurePlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1491355273" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1491685944" format="1.1" version="1"}%
%META:TOPICPARENT{name="Plugins"}%
---+!! Configure Plugin
%FORMFIELD{"Description"}%
Expand Down Expand Up @@ -42,7 +42,8 @@ The plugin uses the =JsonRpcContrib=, which must be installed.

---++ Change History

| 04 Apr 2017: | (1.08) Foswikitask:Item13883: Updated base template to suggest solutions when configure shows base login page. |
| 04 Apr 2017: | (1.08) Foswikitask:Item13883: Updated base template to suggest solutions when configure shows base login page.<br/>\
Foswikitask:Item14366: Reorder initialization to allow local CGI::Carp |
| 23 Jan 2017: | (1.07) Foswikitask:Item14287: Configure needs to encode reported configuration values. |
| 28 Nov 2016: | (1.06) Foswikitask:Item13206: Upgrade to latest jquery-ui |
| 11 Apr 2016: | (1.05) Foswikitask:Item14049: fixed jsonrpc endpoint |
Expand Down
58 changes: 35 additions & 23 deletions JsonRpcContrib/bin/jsonrpc
@@ -1,46 +1,58 @@
#! /usr/bin/env perl
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2011-2015 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. For
# more details read LICENSE in the root of this distribution.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# As per the GPL, removal of this notice is prohibited.

#! /usr/bin/env perl
# See bottom of file for license and copyright information
use strict;
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 {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
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;
$action =~ s/\..*$//; # Remove eventual file extension
$ENV{FOSWIKI_ACTION} = $action;
}

use Foswiki ();
use Foswiki::UI ();
$Foswiki::engine->run();
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2017 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Additional copyrights apply to some or all of the code in this
file as follows:
Copyright (C) 2011-2015 Michael Daum http://michaeldaumconsulting.com
Copyright (C) 1999-2007 Peter Thoeny, peter@thoeny.org
and TWiki Contributors. All Rights Reserved. TWiki Contributors
are listed in the AUTHORS file in the root of this distribution.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1;
As per the GPL, removal of this notice is prohibited.
3 changes: 2 additions & 1 deletion JsonRpcContrib/data/System/JsonRpcContrib.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1480189276" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1491685944" format="1.1" version="1"}%
---+!! %TOPIC%
%FORMFIELD{"Description"}%

Expand Down Expand Up @@ -216,6 +216,7 @@ If a namespace, method, or parameters are specified as part of a JSON-RPC reques
%$DEPENDENCIES%

---++ Change History
| 08 Apr 2017: (2.28) | Foswikitask:Item14366: Reorder initialization to allow local CGI::Carp. |
| 26 Nov 2016: (2.27) | Released with Foswiki 2.1.3.<br>\
Foswikitask:Item14204: redirectto incorrectly encodes Anchors. |
| 04 Apr 2016: (2.26) | Foswikitask:Item14025: Fix issues with JSON::XS 3.02 in some environments. |
Expand Down
6 changes: 3 additions & 3 deletions JsonRpcContrib/lib/Foswiki/Contrib/JsonRpcContrib.pm
Expand Up @@ -21,8 +21,8 @@ BEGIN {
=cut

our $VERSION = '2.27';
our $RELEASE = '26 Nov 2016';
our $VERSION = '2.28';
our $RELEASE = '08 Apr 2017';
our $SHORTDESCRIPTION = 'JSON-RPC interface for Foswiki';
our $NO_PREFS_IN_TOPIC = 1;
our $SERVER;
Expand All @@ -49,7 +49,7 @@ sub getServer {
__END__
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# JsonRpcContrib is Copyright (C) 2011-2016 Michael Daum http://michaeldaumconsulting.com
# JsonRpcContrib is Copyright (C) 2011-2017 Michael Daum http://michaeldaumconsulting.com
# and Foswiki Contributors.
#
# This program is free software; you can redistribute it and/or
Expand Down
12 changes: 7 additions & 5 deletions UnitTestContrib/bin/test
Expand Up @@ -6,20 +6,22 @@ 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 {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
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;
$action =~ s/\..*$//; # Remove eventual file extension
$ENV{FOSWIKI_ACTION} = $action;
}
Expand Down
12 changes: 7 additions & 5 deletions core/bin/attach
Expand Up @@ -6,20 +6,22 @@ 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 {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
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;
$action =~ s/\..*$//; # Remove eventual file extension
$ENV{FOSWIKI_ACTION} = $action;
}
Expand Down
12 changes: 7 additions & 5 deletions core/bin/changes
Expand Up @@ -6,20 +6,22 @@ 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 {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
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;
$action =~ s/\..*$//; # Remove eventual file extension
$ENV{FOSWIKI_ACTION} = $action;
}
Expand Down
12 changes: 7 additions & 5 deletions core/bin/edit
Expand Up @@ -6,20 +6,22 @@ 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 {
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI';
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;
$action =~ s/\..*$//; # Remove eventual file extension
$ENV{FOSWIKI_ACTION} = $action;
}
Expand Down

0 comments on commit e7c2347

Please sign in to comment.