Skip to content

fix: Change the PageIterator logic to avoid making double calls on Current#9236

Open
Hectorhammett wants to merge 1 commit into
mainfrom
fix-paginator
Open

fix: Change the PageIterator logic to avoid making double calls on Current#9236
Hectorhammett wants to merge 1 commit into
mainfrom
fix-paginator

Conversation

@Hectorhammett

Copy link
Copy Markdown
Collaborator

The logic for PageIterator had a hidden bug:
The PageIterator implements the Iterator class and the usage of PHP iterator. If the user were to use the current method on the iterator (eg: $rows->getIterator()->current()) the iterator would check if the first page was filled, if not it would perform an API call.

The way it was setup, calling current without calling rewind would always end up with an API call, meaning that in some cases the users would end up with a repeated API call even when the results where already in memory.

This PR aims to fix that.

@Hectorhammett Hectorhammett requested a review from a team as a code owner June 8, 2026 20:33
@Hectorhammett

Copy link
Copy Markdown
Collaborator Author

This aims to fix #9168

Comment on lines +196 to +198
if (!$this->isInitialized) {
$this->initialize();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but if(!$this->isInitialized) is redundant since we also check that in $this->initialize();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants