Skip to content

Commit

Permalink
Item11860: yes, sorry, this long standing issue was an off by one error.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@15946 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Nov 8, 2012
1 parent 3abcbf6 commit 88dcf8b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
4 changes: 0 additions & 4 deletions UnitTestContrib/test/unit/Fn_SEARCH.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3399,8 +3399,6 @@ FOSWIKI11

sub test_paging_three_webs_second_page_zeroresultsset {
my $this = shift;
$this->expect_failure( 'Item11860 needs to be fixed!',
with_dep => 'Foswiki,>=,1.2' );

my $result = $this->{test_topicObject}->expandMacros(
'%SEARCH{
Expand Down Expand Up @@ -3443,8 +3441,6 @@ FOSWIKI11

sub test_paging_three_webs_third_page_zeroresultsset {
my $this = shift;
$this->expect_failure( 'Item11860 needs to be fixed!',
with_dep => 'Foswiki,>=,1.2' );

my $result = $this->{test_topicObject}->expandMacros(
'%SEARCH{
Expand Down
9 changes: 6 additions & 3 deletions core/lib/Foswiki/Iterator/FilterIterator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ sub skip {
if ( $this->{iterator}->can('skip') ) {
$count = $this->{iterator}->skip($count);

#SMELL, TODO, AAAARGH - don't want to drain the itr, but this is assuming too much.
$this->{next} = $this->{iterator}->{next};
if ( $this->{iterator}->hasNext() ) {
$this->{next} = $this->{iterator}->next();
$this->{pending} = 1;
$count--;
}
}
else {

Expand All @@ -101,7 +104,7 @@ sub skip {

if ( $count >= 0 ) {

#finished.
#skipped past the end of the set
$this->{next} = undef;
$this->{pending} = 0;
}
Expand Down
16 changes: 11 additions & 5 deletions core/lib/Foswiki/Iterator/PagerIterator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ sub hasNext {
$this->skip( $this->{pager_skip_results_from} );

#this already loads $this->{next}

}
else {
if ( $this->{iterator}->hasNext() ) {
Expand All @@ -108,6 +109,7 @@ sub hasNext {
if ( $this->{pending} ) {
if ( $this->{pager_result_count} <= 0 ) {

#SVEN - huh?
#finished.
$this->{next} = undef;
$this->{pending} = 0;
Expand All @@ -130,10 +132,13 @@ sub skip {
if Foswiki::Iterator::MONITOR;

#ask CAN skip() for faster path
if ( $this->{iterator}->can('skip') ) {
$count = $this->{iterator}->skip($count);
$this->{next} = $this->{iterator}->{next};
$this->{pending} = defined( $this->{next} );
if ( 1 == 2 && $this->{iterator}->can('skip') ) {
$count = $this->{iterator}->skip($count);
if ( $this->{iterator}->hasNext() ) {
$this->{next} = $this->{iterator}->next();
$this->{pending} = 1;
$count--;
}
}
else {

Expand All @@ -152,9 +157,10 @@ sub skip {
}
}

#in the bute force method, $count == -1 if there were enough elements.
if ( $count >= 0 ) {

#finished.
#skipped past the end of the set
$this->{next} = undef;
$this->{pending} = 0;
}
Expand Down
3 changes: 3 additions & 0 deletions core/lib/Foswiki/ListIterator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ sub skip {
}
$this->{next} = undef;
my $hasnext = $this->hasNext();
if ($hasnext) {
$count--;
}
print STDERR
"--------------------------------------------ListIterator::skip() => $this->{index} $count, $hasnext\n"
if Foswiki::Iterator::MONITOR;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Search/ResultSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ sub skip {

if ( $count >= 0 ) {

#finished.
#skipped past the end of the set
$this->{next} = undef;
}
print STDERR
Expand Down

0 comments on commit 88dcf8b

Please sign in to comment.