Skip to content

Commit

Permalink
MDL-60357 search: Ensure that the document is valid
Browse files Browse the repository at this point in the history
We were previously testing tha the parent is valid, which it was, and
then fetching the current record, before fetching data from it.

However, the way in which the recordset walk works, the valid function
checks whether the _record_ itself is valid, whilst the current allows
for a callback to be applied.

In this instance, the data-entry was failing because the count of
indexfields was < 2. The recordset data itself was valid, but the view
was not, and as a result, the current() function returned false.

This false was not previously handled.

I've changed the logic so that we handle this case, and have removed a
double-negative in the process.
  • Loading branch information
andrewnicols committed Oct 13, 2017
1 parent 131e607 commit 0049244
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions search/classes/skip_future_documents_iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@ public function key() {
}

public function valid() {
// Check parent.
// Check that the parent is valid.
if (!$this->parent->valid()) {
return false;
}

// See if document is after the cut-off time.
$doc = $this->parent->current();
if ($doc->get('modified') > $this->cutoff) {
return false;
if ($doc = $this->parent->current()) {
// This document is valid if the modification date is before the cutoff.
return $doc->get('modified') <= $this->cutoff;
}

return true;
return false;

}

public function rewind() {
Expand Down

0 comments on commit 0049244

Please sign in to comment.