-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Paginator item counts for empty result sets are inaccurate #6808
Comments
@davidomelettes can you clarify on the requirements? Why is that so? Did you check existing test cases? Consider that the paginator is very frontend-oriented, and from a user perspective, "0" is not a page number. |
The use case which made me consider it a bug was when I used the paginator to display item numbers, rather than page numbers, on my pagination controls. e.g. "31 - 60 of 61 Items" instead of "Page 2 of 3". In the View, if your paginator has no items, the same display will read "1 - 0 of 0 items". It's a trivial issue to work around, but it did make me wonder what the most "correct" values for the paginator page properties should be, with an empty result set. I did check the tests and there is only a single test with an empty result set (testThrowsExceptionWhenCollectionIsEmpty). I created #6809 to address this. |
Actually, if 0 is no more accurate than 1 for firstItemNumber when the result set is empty, perhaps a better solution is simply to not set the properties at all? That would be more in line with how ->previous and ->next work. It depends on how you might answer the question "what is the current page number of a paginator with no pages?" |
You'd still start from the first empty page IMO. |
Handled in #6809 |
…dding missing `@group` annotations for newly introduced test cases
…void multiple internal calls to methods when values are already cached in `$pages`
…endframework#6809-empty-zend-paginator-first-page-starts-with-1' into develop Close zendframework/zendframework#6808 Close zendframework/zendframework#6809
The firstItemNumber property of the pages collection returned by Paginator/Paginator::_createPages() is 1, even if there are no items to be paginated. I feel it would be more accurate if this property had a value of 0 in this case.
The text was updated successfully, but these errors were encountered: