Skip to content

Commit 5fceb41

Browse files
authored
Merge pull request #6584 from WoltLab/62-list-view-page-no-validation
Add missing validation of the page number in list & grid views
2 parents b8ae4be + 24e8f42 commit 5fceb41

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

wcfsetup/install/files/lib/system/gridView/AbstractGridView.class.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,10 @@ protected function validate(): void
768768
if ($titleColumn === null) {
769769
throw new \InvalidArgumentException("Missing title column in grid view with id '{$this->getID()}'.");
770770
}
771+
772+
if ($this->getPageNo() > 1 && $this->getPageNo() > $this->countPages()) {
773+
$this->setPageNo($this->countPages() ?: 1);
774+
}
771775
}
772776

773777
/**

wcfsetup/install/files/lib/system/listView/AbstractListView.class.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ protected function validate(): void
276276
}
277277
}
278278
}
279+
280+
if ($this->getPageNo() > 1 && $this->getPageNo() > $this->countPages()) {
281+
$this->setPageNo($this->countPages() ?: 1);
282+
}
279283
}
280284

281285
protected function getSqlOrderBy(): string

0 commit comments

Comments
 (0)