]> git.koha-community.org Git - koha.git/commit
Bug 33080: Allow pagination to be built from stashed values
authorTomas Cohen Arazi <tomascohen@theke.io>
Fri, 3 Mar 2023 12:28:14 +0000 (09:28 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 21 Mar 2023 07:41:43 +0000 (07:41 +0000)
commit5455fcd3718677b0a7fb33ece113d95fe5d9bc1e
tree18c548584de047916aabe07eb7784ba197cd769e
parentd1f3c6e806872e597c31a463fd177c704cc55e03
Bug 33080: Allow pagination to be built from stashed values

The way the old `objects.search` was build implied several totals were
calculated there, and passed to the `$c->add_pagination_headers` helper.

With the introduction of `objects.search_rs` and the ability of doing
things to the resultset afterwards, it felt like out of place to have
the pagination headers be implicitly set inside `objects.search_rs`.

This patch makes the search_rs stash some required values (from the original request) and
makes `add_pagination_headers` accept those values. This way other
callers can still build their own pagination values, while allowing this
simplified implementation.

Full-stack tests still pass, and the helper tests are moved to the
`db_dependent` section and are now more meaningful as well

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
   $ prove t/db_dependent/Koha/REST/Plugin/Pagination.t \
           t/db_dependent/api/v1/
=> SUCCESS: Tests pass! Nothing broken!
3. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit ad83d2e07d3c2c28e962b1a2e8d04b6f25a4a868)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/REST/Plugin/Objects.pm
Koha/REST/Plugin/Pagination.pm
t/Koha/REST/Plugin/Pagination.t [deleted file]
t/db_dependent/Koha/REST/Plugin/Pagination.t [new file with mode: 0755]