Skip to content

Commit

Permalink
Item13897: Intermidiate, converted checkers.
Browse files Browse the repository at this point in the history
Also some improvements to error handling has been done. Trying to get rid
of as much of eval's as possible in cases where it's used to load a module.

- Another significat change is introduction of attrs attribute on
Foswiki::Configure::Item objects. It is used to hold all serializable keys
– i.e. those which names are not started with underscore. This is somewhat
of a headache across the Configure code because previously all keys were
stored directly on the object hash. Now non-serializable keys must have
their own attributes (like _parent, for instance). For example, old code:

$item->{serializable}
$item->{_nonserializable}

must be replaced with:

$item->attrs->{serializable}
$item->_nonserializable

Perhaps the children key shall get its own attribute too but I left it for
later.

- Moved redirect() method to Foswiki::App.

- Improved Foswiki::Config localization code by localizing not only data
but files and urlHost attributes too.

- Added TO_JSON method to Foswiki::Exception to take care of cases when
eval hides a thrown exception and interprets it as a response for a JsonRPC
request. This happened to Store::Implementation checker code leading to
JSON failing to encode response object.

- Added Foswiki::Exception::errorStr static method to convert an error
object of unknown type (i.e. a string from die, or a Foswiki::Exception or
Error descendants) into a plain string. For blessed references it is using
stringify or text methods in the order given.

- Fixed a bug in store encoding checked which was causing a regexp match
agains unitialized {Store}{Encoding} key during bootstrapping stage.
  • Loading branch information
vrurg committed Apr 27, 2016
1 parent 2a64d31 commit 50c1382
Show file tree
Hide file tree
Showing 147 changed files with 1,124 additions and 1,187 deletions.
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::Plugins::CommentPlugin::GuestCanComment;
use v5.14;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Moo;
extends qw(Foswiki::Configure::Checker);

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::Plugins::CommentPlugin::RequiredForSave;
use v5.14;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Moo;
extends qw(Foswiki::Configure::Checker);

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::Plugins::CompareRevisionsAddonPlugin::Enabled;
use v5.14;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Moo;
extends qw(Foswiki::Configure::Checker);

sub check {
my ( $this, $value ) = @_;
Expand Down
@@ -1,12 +1,12 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::SwitchBoard::compareauth;
use v5.14;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
use File::Spec();
our @ISA = qw( Foswiki::Configure::Checker );

use Moo;
use namespace::clean;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::Plugins::EditRowPlugin::Enabled;
use v5.14;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Moo;
extends qw(Foswiki::Configure::Checker);

sub check {
my ( $this, $value ) = @_;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::Plugins::EditRowPlugin::Macro;
use v5.14;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Moo;
extends qw(Foswiki::Configure::Checker);

sub check {
my ( $this, $value ) = @_;
Expand Down
@@ -1,12 +1,12 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::JQueryVersion;
use v5.14;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
use File::Spec();
our @ISA = qw( Foswiki::Configure::Checker );

use Moo;
use namespace::clean;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Autocomplete::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Bgiframe::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Corner::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Gradient::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Media::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Nifty::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Rating::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Shake::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::SimpleModal::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Supersubs::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Tmpl::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Tooltip::Enabled;
use v5.14;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );
use Moo;
extends qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
Expand Down
28 changes: 20 additions & 8 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Plugins.pm
Expand Up @@ -4,6 +4,7 @@ package Foswiki::Plugins::JQueryPlugin::Plugins;
use strict;
use warnings;
use Foswiki::Func();
use Try::Tiny;

my @iconSearchPath;
my %iconCache;
Expand Down Expand Up @@ -282,17 +283,28 @@ sub load {

unless ( defined $pluginDesc->{instance} ) {

eval "require $pluginDesc->{class};";

if ($@) {
Foswiki::Func::writeDebug(
"ERROR: can't load jQuery plugin $pluginName: $@");
$pluginDesc->{instance} = 0;
}
else {
try {
Foswiki::load_class( $pluginDesc->{class} );
$pluginDesc->{instance} =
$Foswiki::app->create( $pluginDesc->{class} );
}
catch {
my $errStr = Foswiki::Exception::errorStr($_);
Foswiki::Func::writeDebug(
"ERROR: can't load jQuery plugin $pluginName: $errStr");
$pluginDesc->{instance} = 0;
};

#eval "require $pluginDesc->{class};";
#if ($@) {
# Foswiki::Func::writeDebug(
# "ERROR: can't load jQuery plugin $pluginName: $@");
# $pluginDesc->{instance} = 0;
#}
#else {
# $pluginDesc->{instance} =
# $Foswiki::app->create( $pluginDesc->{class} );
#}
}

return $pluginDesc->{instance};
Expand Down
7 changes: 5 additions & 2 deletions JsonRpcContrib/lib/Foswiki/Contrib/JsonRpcContrib/Response.pm
Expand Up @@ -32,10 +32,13 @@ has id => ( is => 'rw', );
has message => ( is => 'rw', );
has code => ( is => 'rw', lazy => 1, default => 0, );
has json => (
is => 'rw',
is => 'ro',
lazy => 1,
default => sub {
return JSON->new->pretty(DEBUG)->convert_blessed(1);
my $json = JSON->new;
$json->pretty(DEBUG);
$json->convert_blessed(1);
return $json;
},
);

Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::Plugins::MailerContribPlugin::Enabled;
use v5.14;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Moo;
extends qw(Foswiki::Configure::Checker);

sub check {
my ( $this, $value ) = @_;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::Plugins::MailerContribPlugin::Module;
use v5.14;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Moo;
extends qw(Foswiki::Configure::Checker);

sub check {
my ( $this, $value ) = @_;
Expand Down
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::Extensions::PlainFileStoreContrib::CheckForRCS;
use v5.14;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Moo;
extends qw(Foswiki::Configure::Checker);

my @required = (

Expand Down

0 comments on commit 50c1382

Please sign in to comment.