Skip to content

Commit 53b2fe1

Browse files
Merge pull request #1 from RobertWeideKyos/patch-1
Fix issue with out of bounds log index
2 parents 0f8ca74 + 4dcf8d5 commit 53b2fe1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Readers/IndexedLogReader.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ public function paginate(int $perPage = 25, ?int $page = null)
236236
{
237237
$page = $page ?: Paginator::resolveCurrentPage('page');
238238

239-
if (! is_null($this->onlyShowIndex)) {
239+
if (! is_null($this->onlyShowIndex) && $index = $this->reset()->getLogAtIndex($this->onlyShowIndex)) {
240240
return new LengthAwarePaginator(
241-
[$this->reset()->getLogAtIndex($this->onlyShowIndex)],
241+
[$index],
242242
1,
243243
$perPage,
244244
$page
@@ -291,7 +291,9 @@ public function percentScanned(): int
291291

292292
protected function getLogAtIndex(int $index): ?Log
293293
{
294-
$position = $this->index()->getPositionForIndex($index);
294+
if (! $position = $this->index()->getPositionForIndex($index)) {
295+
return null;
296+
}
295297

296298
$text = $this->getLogTextAtPosition($position);
297299

0 commit comments

Comments
 (0)