Skip to content

Navigation Menu

Sign in
Sign up

fix: Rewind iterator before calling current/next - #2218

Open
CarlSchwan wants to merge 1 commit into
master from
carl/rewind
Open

fix: Rewind iterator before calling current/next #2218
CarlSchwan wants to merge 1 commit into
master from
carl/rewind

Conversation

@CarlSchwan

@CarlSchwan CarlSchwan commented Sep 1, 2026

Copy link
Copy Markdown
Member

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@@ -71,6 +71,7 @@ public function get($query = '', $count = 50, $offset = 0): JSONResponse {
*/
private function getLastItem() {
$iterator = $this->logIteratorFactory->getLogIterator($this->settingsService->getShownLevels());

@Antreesy Antreesy Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This already does rewind on creating from class, and calling next() once - so it should be on the latest line already:

$this->logIteratorFactory->getLogIterator($this->settingsService->getShownLevels());
	...
	new LogIterator($handle, $dateFormat, $timezone);
		...
		__construct($handle, string $dateFormat, string $timezone) {
			...
			$this->rewind();
				...
				$this->next();

What does it fix? I remember investigating something with it, but didn't finish. But not sure that current code brings something to it

@CarlSchwan CarlSchwan Sep 1, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Before the fix I always got null has return from getLastItem

@come-nc come-nc Sep 1, 2026

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.

There is something weird going on because I agree with @Antreesy the code is supposed to return a rewinded iterator already from the factory

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@come-nc come-nc come-nc left review comments
@Antreesy Antreesy Antreesy left review comments

At least 1 approving review is required to merge this pull request.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /