Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Controller/LogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

$iterator->rewind();
return $iterator->current();
}

Expand Down Expand Up @@ -102,6 +103,7 @@ public function poll(string $lastReqId): JSONResponse {
}

$iterator = $this->logIteratorFactory->getLogIterator($this->settingsService->getShownLevels());
$iterator->rewind();
$iterator->next();

$data = [];
Expand Down
Loading