Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item13897: Fixed Foswiki::Class incompatibility with perl 5.20 and lo…
…wer.

Some bootstrap fixed.
  • Loading branch information
vrurg committed Sep 3, 2016
1 parent 0753fd2 commit f9504fd
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
16 changes: 9 additions & 7 deletions core/lib/Foswiki/Class.pm
Expand Up @@ -117,7 +117,8 @@ sub import {
if ( exists $options{$param} ) {
my $opt = $options{$param};
$opt->{use} = 1;
push @noNsClean, @{ $opt->{keywords} } if defined $opt->{keywords};

#push @noNsClean, @{ $opt->{keywords} } if defined $opt->{keywords};
}
else {
push @p, $param;
Expand All @@ -138,6 +139,7 @@ sub import {
require feature;
feature->import($featureSet);

require namespace::clean;
namespace::clean->import(
-cleanee => $target,
-except => \@noNsClean,
Expand Down Expand Up @@ -170,17 +172,17 @@ sub _assign_role {
push @{ $_assignedRoles{$class} }, $role;
}

sub _handler_callbacks {
my $target = caller;
Foswiki::Aux::Callbacks::registerCallbackNames( $target, @_ );
}

sub _install_callbacks {
my ( $class, $target ) = @_;

Foswiki::load_package('Foswiki::Aux::Callbacks');
_assign_role( $target, 'Foswiki::Aux::Callbacks' );
_inject_code( $target, "callback_names", \&_handler_callbacks );
}

sub _handler_callbacks (@) {
my $target = caller;
Foswiki::Aux::Callbacks::registerCallbackNames( $target, @_ );
_inject_code( $target, "callback_names", *_handler_callbacks );
}

sub _install_app {
Expand Down
15 changes: 11 additions & 4 deletions core/lib/Foswiki/Configure/Auth.pm
Expand Up @@ -2,9 +2,11 @@

package Foswiki::Configure::Auth;

use strict;
use warnings;

use Foswiki::Func;
use Foswiki::AccessControlException;
use Foswiki::Contrib::JsonRpcContrib::Error;

=begin TML
Expand All @@ -14,9 +16,6 @@ Implements authorization checking for access to configure.
=cut

use strict;
use warnings;

=begin TML
---++ StaticMethod checkAccess( $app, $die )
Expand Down Expand Up @@ -53,6 +52,12 @@ sub checkAccess {
}
unless ($authorized) {
if ($json) {

# NOTE Don't pre-load this module because it'll break
# tools/configure when JsonRpcContrib isn't installed
# (yet).
Foswiki::load_package(
"Foswiki::Contrib::JsonRpcContrib::Error");
throw Foswiki::Contrib::JsonRpcContrib::Error( -32600,
'Access to configure denied by {FeatureAccess}{Configure} Setting'
);
Expand All @@ -71,6 +76,8 @@ sub checkAccess {
else {
unless ( Foswiki::Func::isAnAdmin() ) {
if ($json) {
Foswiki::load_package(
"Foswiki::Contrib::JsonRpcContrib::Error");
throw Foswiki::Contrib::JsonRpcContrib::Error( -32600,
'Access to configure denied for non-admin users' );
}
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Foswiki/UI/Configure.pm
Expand Up @@ -13,8 +13,8 @@ use v5.14;

use Assert;

use Foswiki ();
use Foswiki::Configure::Auth ();
use Foswiki ();
require Foswiki::Configure::Auth;

use Moo;
use namespace::clean;
Expand Down
9 changes: 4 additions & 5 deletions core/lib/Foswiki/Users.pm
Expand Up @@ -60,10 +60,8 @@ to a user.
use Foswiki::AggregateIterator ();
use Foswiki::LoginManager ();

use Moo;
use namespace::clean;
use Foswiki::Class qw(app);
extends qw(Foswiki::Object);
with qw(Foswiki::AppObject);

use Assert;

Expand Down Expand Up @@ -135,15 +133,16 @@ sub BUILD {
my $app = $this->app;

# making basemapping
my $implBaseUserMappingManager = $Foswiki::cfg{BaseUserMappingManager}
my $implBaseUserMappingManager = $app->cfg->data->{BaseUserMappingManager}
|| 'Foswiki::Users::BaseUserMapping';
Foswiki::load_package($implBaseUserMappingManager);

#eval "require $implBaseUserMappingManager";
#Foswiki::Exception::Fatal->throw( text => $@ ) if $@;
$this->basemapping( $this->create($implBaseUserMappingManager) );

my $implUserMappingManager = $Foswiki::cfg{UserMappingManager} || 'none';
my $implUserMappingManager = $app->cfg->data->{UserMappingManager}
|| 'none';
$implUserMappingManager = 'Foswiki::Users::TopicUserMapping'
if ( $implUserMappingManager eq 'none' );

Expand Down
25 changes: 22 additions & 3 deletions core/tools/configure
Expand Up @@ -31,6 +31,7 @@ use Getopt::Long;
use Storable qw(dclone);
use Pod::Usage ();
use Data::Dumper ();
use Try::Tiny;

# Assume we are in the tools dir, and we can find bin and lib from there
use FindBin;
Expand All @@ -45,8 +46,9 @@ binmode( STDIN, ':crlf' );
use Assert;

use Foswiki;
use Foswiki::Configure::Query;
use Foswiki::App;
use Foswiki::Exception;
require Foswiki::Configure::Query;

{

Expand Down Expand Up @@ -97,7 +99,7 @@ use Foswiki::App;
$orig->( $this, $k );

print Encode::encode_utf8(
"\$Foswiki::cfg$k = " . $this->changes->{$k} . ";\n");
"\$Foswiki::cfg$k = " . $this->changes->{$k} . ";\n" );
};

around WIZARD => sub {
Expand Down Expand Up @@ -258,7 +260,24 @@ sub _prompt {
#$Foswiki::Configure::LoadSpec::RAW_VALS = 1;

# Initialise
my $app = Foswiki::App->new( env => dclone( \%ENV ), );

$SIG{__DIE__} = sub {

# Somehow overriding of __DIE__ clashes with remote perl debugger in
# Komodo unless we die again instantly.
die $_[0] if (caller)[0] =~ /^DB::/;
Foswiki::Exception::Fatal->rethrow( $_[0] );
};

my $app;
try {
$app = Foswiki::App->new( env => dclone( \%ENV ), );
}
catch {
my $e = $_;
say STDERR "App creation failed:", Foswiki::Exception::errorStr($e);
exit 1;
};

# Force config re-read to be independant of any possible variations in config
# constructor.
Expand Down

0 comments on commit f9504fd

Please sign in to comment.