Merge branch 'MDL-55356-master' of https://github.com/sammarshallou/moodle
[moodle.git] / search / classes / manager.php
index 4e85cc7..ea95108 100644 (file)
@@ -715,8 +715,10 @@ class manager {
             if ($timelimit) {
                 $options['stopat'] = $stopat;
             }
-            $iterator = new \core\dml\recordset_walk($recordset, array($searcharea, 'get_document'), $options);
+            $iterator = new skip_future_documents_iterator(new \core\dml\recordset_walk(
+                    $recordset, array($searcharea, 'get_document'), $options));
             $result = $this->engine->add_documents($iterator, $searcharea, $options);
+            $recordset->close();
             if (count($result) === 5) {
                 list($numrecords, $numdocs, $numdocsignored, $lastindexeddoc, $partial) = $result;
             } else {