Skip to content

Commit

Permalink
Item14861: fix broken copy cgi script
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Nov 12, 2019
1 parent 3ab689b commit 732cee7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
9 changes: 5 additions & 4 deletions bin/copy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ 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);
Expand All @@ -31,10 +36,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;
$action =~ s/\..*$//; # Remove eventual file extension
$ENV{FOSWIKI_ACTION} = $action;
}
Expand Down
3 changes: 2 additions & 1 deletion data/System/CopyContrib.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1564156088" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1573547052" format="1.1" version="1"}%
---+!! %TOPIC%
%FORMFIELD{"Description"}%

Expand Down Expand Up @@ -199,6 +199,7 @@ All parameters of the [[##Mode:_61topic_61][topic mode]] apply to each topic in
---++ Change History

%TABLE{columnwidths="7em" tablewidth="100%"}%
| 12 Nov 2019: | fix copy cgi script |
| 26 Jul 2019: | fix use of store; create a new revision when copying attachments instead of erasing anything that existed before |
| 11 Jun 2019: | added =copy= perl api; added =nohandlers= option; fixed copying attachments |
| 21 Nov 2018: | added =trashsource= to topic agent; fixed memory leaks |
Expand Down
12 changes: 8 additions & 4 deletions lib/Foswiki/Contrib/CopyContrib.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use Error qw( :try );
use Encode();
use Foswiki::OopsException ();

our $VERSION = '4.00';
our $RELEASE = '26 Jul 2019';
our $VERSION = '4.01';
our $RELEASE = '12 Nov 2019';
our $SHORTDESCRIPTION = 'Copies webs, topics, attachments, or part of them';

our %agentImpls = (
Expand Down Expand Up @@ -53,7 +53,9 @@ sub copy {
my $impl = $agentImpls{$mode};
throw Error::Simple("Unknown copy mode '$mode'") unless defined $impl;

eval "require $impl";
my $path = $impl . '.pm';
$path =~ s/::/\//g;
eval {require $path};
throw Error::Simple($@) if $@;

my $session = $Foswik::Plugins::SESSION;
Expand Down Expand Up @@ -89,7 +91,9 @@ sub copyCgi {
my $impl = $agentImpls{$mode};
throw Error::Simple("Unknown copy mode '$mode'") unless defined $impl;

eval "require $impl";
my $path = $impl . '.pm';
$path =~ s/::/\//g;
eval {require $path};
throw Error::Simple($@) if $@;

my $agent = $impl->new($session);
Expand Down

0 comments on commit 732cee7

Please sign in to comment.