Releases: Automattic/stream-builder
CursorlessFilteredStream allows more retries when whole pages are filtered
We have updated CursorlessFilteredStream
The problem:
When a fetched batch contains only filtered-out elements, CursorlessFilteredStream counts it against the retry budget. After retry_count retries, pagination stops with an empty result and no cursor — even though the inner stream has more content.
The solution:
Preserve the retry budget when a page yields zero retained results. Retries are only consumed when partial progress is made. The inner stream's natural exhaustion still guarantees termination.
This solution could result in deeper recursion, and resulting in memory issues. This could happen if we have a huge block of filtered elements.
Lets say that we paginate by 10 elements, and we have 30 consecutive elements being filtered. This change addresses that issue by not counting "depth" for empty pages.
Previous version 1.0
page 1 => 8 elements - depth 2
page 2 => 10 filtered elements - depth 1
Current version 1.1
page 1 => 8 elements - depth 2
page 2 => 10 filtered elements - depth 1
page 3 => 10 filtered elements - depth 1
page 3 => 10 filtered elements - depth 1
page 4 => 5 elements - depth 0
If we make little progress by finding some elements in subsequent pages (inner enumeration), we will decrement retry count (depth). but when we have a big chunk of filtered elements, we will be able to skip the whole block and fetch a few more elements from a subsequent page.
How to deactivate this functionality
If you notice that this goes too deep and causes memory issues, you can turn it off by setting skip_empty_pages optional property to false. It has been made true as default because we consider this change to be a bug fix.
PHP 8.4 compatibility
What's Changed
Full Changelog: 0.12.1...1.0.0
Improve FilteredStream by reducing premature exhaustion when retries are enabled
0.12.0
0.11.2
0.11.1
0.11.0
0.10.1
0.10.0
What's Changed
- Test on PHP 8.3 by @sanmai in #29
- implement release_all_elements method on StreamTracer. Make StreamFilter trace an event when all the elements have been released by the filter. by @lucila in #30
- add release ratio to meta field on the end_filter tracer method. Update StreamFilter so that we can trace the release ratio of the filter step. by @lucila in #31
Full Changelog: 0.9.2...0.10.0