Problem/Motivation
When using a custom querystring key in the pagerer module, for "one-based" page index, the overview of the taxonomy terms pagination breaks. For example: When using "pg" as querysting key, the pagerer module will convert the url on the taxonomy overview (example for tags): /admin/structure/taxonomy/manage/tags/overview?pg=2 . This results in exactly the same terms that are listed on the first page. When we look at web/core/modules/taxonomy/src/Form/OverviewTerms.php, the page index is retrieved by:
$page = $this->getRequest()->query->get('page') ?: 0;
So the taxonomy overview form, will never take the custom querystring into account.
Steps to reproduce
- On the pagerer url settings, provide a custom querystring key and select "one-based" as page index.
- Go to a taxonomy overview page, with a sufficient amount of terms, so that a pager will be visible.
- Click on "next" or "2" in the pager.
- New page will load, but the terms are still the same.
Proposed resolution
Use the new PagerManager::findPage() method, instead.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 3170185-18.patch | 766 bytes | mondrake |
Comments
Comment #2
gvert commentedComment #3
mondrakeThanks for the report.
IMHO this is a core issue, specifically an oversight in the conversion of the pager to services in #2044435: Convert pager.inc to a service.
The current page number should be determined by calling
::findPagefrom the 'pager.parameters' service, not directly from the request object. Pagerer overrides the 'pager.parameters' service to return it from the custom querystring, but cannot do anything if the request is accessed directly.Moving to core issue queue.
Comment #4
mondrakeThat's the idea, let's see if tests pass... I do not know how we could add specific testing for this though.
Comment #6
mondrakeIt's a good idea to put the medicament in the syringe, for an injection.
Comment #7
gvert commentedI have applied the "3170185-6.patch" patch on drupal 9.1 dev version. The pager on a taxonomy overview list, works now in combination with the pagerer module with a custom key in the querystring. Thanks mondrake!
Comment #8
alexpottI don't think we need a CR here. So the link is not required.
This seems really awkward to have to inject both of these services. I think given the example code in \Drupal\Core\Pager\PagerManagerInterface::createPager() it'd be nice to implement PagerManagerInterface::findPage() that calls through to the pager parameters service. I wonder if we should open a follow-up for that. Because then we could remove the service injection.
Comment #9
mondrakeFiled follow-up #3173636: Implement a PagerManagerInterface::findPage() method, for D10 - we'd break BC for contrib if we did that earlier.
Fixed the @trigger_error.
Back to RTBC since the change is only to an untested deprecation error string.
Comment #10
mondrakeComment #11
larowlanWe would ordinarily require a deprecation test to go with a new deprecation
Can we get a simple test that checks the correct deprecation error is emitted in that scenario.
Comment #12
larowlanComment #13
mondrakeNot sure about adding a test only for the additional constructor arguments. At least #3096648: Add support for third party libraries in site specific and install profile specific libraries folders and #3101299: Install module from .zip URL fails did not introduce one. Can we clarify the policy before adding one?
Comment #14
alexpottRe #11 @catch and I have discussed this before and agreed that deprecation testing for only a constructor change like this is unnecessary. If there is more logic in the constructor than a simple is not null check then a test is required but that's not the case here.
Comment #15
larowlanOk, I wasn't aware of that decision.
I'll update the 'how' section of the docs tomorrow
Comment #16
mondrake#3173636: Implement a PagerManagerInterface::findPage() method is making good progress, so I suggest to wait for that to go in, which will make this patch much simpler.
Comment #18
mondrake#3173636: Implement a PagerManagerInterface::findPage() method was committed, and now the fix is just a one-liner.
Comment #19
mondrake#3173636: Implement a PagerManagerInterface::findPage() method was committed, and now the fix is just a one-liner.
Comment #20
mondrakeComment #21
paulocsConfirm that patch #18 solves the problem with the right approach after #3173636: Implement a PagerManagerInterface::findPage() method was committed.
Moving to RTBC.
Comment #22
andypostAs a bug it needs -fail.patch steps in summary looks great for scenario
Comment #23
paulocsComment #24
mondrakeYou can't test this unless you swap the service, which would require developing a test module for. Not sure it's worth it. Existing tests already work in the sense that the change is behaving (for core) exactly as if the page is extracted from the request.
Comment #25
paulocsYes, I was trying to write tests for it but did not find a way. I just can confirm that it fixes the problem related on the issue summary.
Maybe screenshots are enough?
Comment #26
mondrakeComment #28
catchAgreed this is OK without an explicit test, it's a refactor to use the correct API that enables contrib to override properly.
Committed/pushed to 9.2.x, thanks!