Skip to content

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

Open
CarlSchwan wants to merge 1 commit into
masterfrom
carl/rewind
Open

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

Conversation

@CarlSchwan

Copy link
Copy Markdown
Member

馃 AI (if applicable)

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

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
@CarlSchwan CarlSchwan self-assigned this Sep 1, 2026
@@ -71,6 +71,7 @@ public function get($query = '', $count = 50, $offset = 0): JSONResponse {
*/
private function getLastItem() {
$iterator = $this->logIteratorFactory->getLogIterator($this->settingsService->getShownLevels());

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

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

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants