File tree 3 files changed +11
-2
lines changed
3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ All notable changes to this project will be documented in this file based on the
37
37
### Improvements
38
38
* Added ` native_function_invocation ` CS rule [ #1606 ] ( https://github.com/ruflin/Elastica/pull/1606 )
39
39
* Elasticsearch test version changed from 6.5.2 to 6.6.1 [ #1620 ] ( https://github.com/ruflin/Elastica/pull/1620 )
40
+ * Clear scroll context also when empty page was received [ #1660 ] ( https://github.com/ruflin/Elastica/pull/1660 )
40
41
41
42
### Deprecated
42
43
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ public function next()
85
85
} else {
86
86
// If there are no pages left, we do not need to query ES.
87
87
$ this ->clear ();
88
+ $ this ->_currentResultSet = null ;
88
89
}
89
90
}
90
91
@@ -147,7 +148,6 @@ public function clear()
147
148
148
149
// Reset scroll ID so valid() returns false.
149
150
$ this ->_nextScrollId = null ;
150
- $ this ->_currentResultSet = null ;
151
151
}
152
152
}
153
153
@@ -164,7 +164,13 @@ protected function _setScrollId(ResultSet $resultSet)
164
164
165
165
$ this ->_currentResultSet = $ resultSet ;
166
166
++$ this ->currentPage ;
167
- $ this ->_nextScrollId = $ resultSet ->getResponse ()->isOk () && $ resultSet ->count () > 0 ? $ resultSet ->getResponse ()->getScrollId () : null ;
167
+ $ this ->_nextScrollId = null ;
168
+ if ($ resultSet ->getResponse ()->isOk ()) {
169
+ $ this ->_nextScrollId = $ resultSet ->getResponse ()->getScrollId ();
170
+ if (0 === $ resultSet ->count ()) {
171
+ $ this ->clear ();
172
+ }
173
+ }
168
174
}
169
175
170
176
/**
Original file line number Diff line number Diff line change @@ -95,6 +95,8 @@ public function testEmptyScroll()
95
95
96
96
$ this ->assertEquals (0 , $ scroll ->current ()->count ());
97
97
$ this ->assertFalse ($ scroll ->valid ());
98
+
99
+ $ this ->_assertOpenSearchContexts ($ search ->getClient (), 0 );
98
100
}
99
101
100
102
/**
You can’t perform that action at this time.
0 commit comments