Skip to content

Commit

Permalink
Item13897: Bug fixes.
Browse files Browse the repository at this point in the history
Only 15 tests of Fn_SEARCH are failing.
  • Loading branch information
vrurg committed Feb 12, 2016
1 parent 6c5d460 commit 68a4264
Show file tree
Hide file tree
Showing 7 changed files with 250 additions and 218 deletions.
3 changes: 2 additions & 1 deletion core/lib/Foswiki.pm
Expand Up @@ -2641,7 +2641,8 @@ sub finish {
undef $Foswiki::Plugins::SESSION;

if (DEBUG) {
my $remaining = join ',', grep { defined $this->{$_} } keys %$this;
my $remaining = join ',',
grep { defined $this->{$_} && $_ !~ /^__/ } keys %$this;
ASSERT( 0,
"Fields with defined values in "
. ref($this)
Expand Down
10 changes: 5 additions & 5 deletions core/lib/Foswiki/AccessControlException.pm
Expand Up @@ -95,11 +95,11 @@ BEGIN {

our @_newParameters = qw( mode user web topic reason );

has web => ( is => 'ro' );
has topic => ( is => 'ro' );
has user => ( is => 'ro' );
has mode => ( is => 'ro' );
has reason => ( is => 'ro' );
has web => ( is => 'ro', required => 1, );
has topic => ( is => 'ro', required => 1, );
has user => ( is => 'ro', required => 1, );
has mode => ( is => 'ro', required => 1, );
has reason => ( is => 'ro', required => 1, );

=begin TML
Expand Down
29 changes: 16 additions & 13 deletions core/lib/Foswiki/Form.pm
Expand Up @@ -70,9 +70,11 @@ has def => (
predicate => 1,
);
has fields => (
is => 'rw',
lazy => 1,
clearer => 1,
is => 'rw',
lazy => 1,
clearer => 1,
predicate => 1,
isa => Foswiki::Object::isaARRAY( 'fields', noUndef => 1, ),
);
has mandatoryFieldsPresent => (
is => 'rw',
Expand Down Expand Up @@ -127,7 +129,6 @@ sub _validateWebTopic {
# XXX vrurg ClassMethod load() is supposed to replace the old new() method and
# become a new constructor. Required to stay in compliance with Moo architecture
# and avoid replacing of the standard new() method.
# SMELL Foswiki::Meta already defines load() method. Need another name.
sub loadCached {
my ( $class, $session, $web, $form, $def ) = @_;

Expand All @@ -142,7 +143,8 @@ sub loadCached {
}
}

return $this // $class->new(
return $this if defined $this;
return $class->new(
session => $session,
web => $vweb,
form => $vtopic,
Expand All @@ -166,7 +168,7 @@ around BUILDARGS => sub {

# Avoid direct calls to $class::new().
ASSERT( $params->{_indirect},
"${class}::new() has been use directly. Use ${class}->loadCached() instead."
"${class}::new() has been used directly. Use ${class}->loadCached() instead."
);

# No more need to pollute properties with this key.
Expand All @@ -175,11 +177,11 @@ around BUILDARGS => sub {
# Got to have either a def or a topic
unless ( $params->{def} || $session->topicExists( $vweb, $vtopic ) ) {
Foswiki::OopsException->throw(
'attention',
def => 'no_form_def',
web => $session->webName,
topic => $session->topicName,
params => [ $vweb, $vtopic ]
template => 'attention',
def => 'no_form_def',
web => $session->webName,
topic => $session->topicName,
params => [ $vweb, $vtopic ]
);
}

Expand Down Expand Up @@ -213,6 +215,9 @@ sub BUILD {
# Foswiki::Meta object
$this->fields( $this->_extractPseudoFieldDefs( $this->def ) );
}

ASSERT( $this->has_fields, "No fields arg cpecified" );
ASSERT( defined $this->fields, "No fields defined" );
}

=begin TML
Expand Down Expand Up @@ -479,7 +484,6 @@ sub createField {
"error compiling class $class: $@" );

# Type not available; use base type
require Foswiki::Form::FieldDefinition;
$class = 'Foswiki::Form::FieldDefinition';
}
return $class->new( session => $this->session, type => $type, @_ );
Expand Down Expand Up @@ -813,7 +817,6 @@ sub _extractPseudoFieldDefs {
my ( $this, $meta ) = @_;
my @fields = $meta->find('FIELD');
my @fieldDefs;
require Foswiki::Form::FieldDefinition;
foreach my $field (@fields) {

# Fields are name, value, title, but there is no other type
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Iterator/PagerIterator.pm
Expand Up @@ -39,7 +39,7 @@ has pagesize => (
);
has showpage => (
is => 'ro',
coerce => sub { return defined( $_[0] ? $_[0] : 1 ); },
coerce => sub { return defined( $_[0] ) ? $_[0] : 1; },
);
has pending => (
is => 'rw',
Expand Down
30 changes: 26 additions & 4 deletions core/lib/Foswiki/Object.pm
Expand Up @@ -20,10 +20,11 @@ features.
=cut

use Foswiki::Exception;
use Assert;
use Moo;
use namespace::clean;

use Assert;

=begin TML
---++ ClassMethod BUILDARGS()
Expand Down Expand Up @@ -63,6 +64,9 @@ This limitation will remain actual until constructor are no more called with pos
=cut

has __orig_file => ( is => 'rw', clearer => 1, );
has __orig_line => ( is => 'rw', clearer => 1, );

sub BUILDARGS {
my ( $class, @params ) = @_;

Expand Down Expand Up @@ -118,19 +122,37 @@ sub BUILDARGS {
return $paramHash;
}

sub BUILD {
my $this = shift;

if (DEBUG) {
my ( $pkg, $file, $line );
my $sFrame = 0;
do {
( $pkg, $file, $line ) = caller( ++$sFrame );
} while (
$pkg =~ /^(Foswiki::Object|Moo::|Method::Generate::Constructor)/ );
$this->__orig_file($file);
$this->__orig_line($line);
}

}

sub finish {

# Plug for objects with no finish() method. Temporary, until the destruction
# stage is reviewed.
}

sub DEMOLISH {
my $self = shift;
if ( $self->can('finish') ) {
my $this = shift;
$this->_clear__orig_file;
$this->_clear__orig_line;
if ( $this->can('finish') ) {

# SMELL every Foswiki::Object ancestor has to use DEMOLISH as the standard.
# XXX We have to generate a warning if this condition is met.
$self->finish;
$this->finish;
}

}
Expand Down
10 changes: 6 additions & 4 deletions core/lib/Foswiki/Store/SearchAlgorithms/PurePerl.pm
Expand Up @@ -134,7 +134,9 @@ sub _webQuery {
Foswiki::Search::InfoCache::getTopicListIterator( $webObject,
$options );
}
ASSERT( UNIVERSAL::isa( $topicSet, 'Foswiki::Iterator' ) ) if DEBUG;
ASSERT( UNIVERSAL::isa( $topicSet, 'Foswiki::Object' )
&& $topicSet->does('Foswiki::Iterator') )
if DEBUG;

#print STDERR "######## PurePerl search ($web) tokens "
#.scalar(@{$query->tokens()})." : ".join(',', @{$query->tokens()})."\n";
Expand Down Expand Up @@ -207,9 +209,9 @@ sub _webQuery {
}

$topicSet = Foswiki::Search::InfoCache->new(
session => $Foswiki::Plugins::SESSION,
web => $web,
topicList => \@scopeTextList
session => $Foswiki::Plugins::SESSION,
defaultWeb => $web,
topicList => \@scopeTextList
);
}

Expand Down

0 comments on commit 68a4264

Please sign in to comment.