Problem/Motivation
The query extender PagerDefault doesn't check if there are already global defined pagers. The class starts an own counting of pagers by using static $maxElement = 0;.
If you've already defined pagers by pager_default_initialize() the query extender will overwrite them as soon as the query is executed.
Proposed resolution
Get rid of static $maxElement = 0; and use the global variable $pager_page_array in ensureElement() to ensure an unique pager id is used for the query extender.
Remaining tasks
Clarify if there are cases in which this handling could lead to unexpected errors.
User interface changes
None
API changes
No real API changes, but the signature of the class PagerDefault will change a bit as static $maxElement = 0; is removed.
Comments
Comment #2
das-peter commentedBlargh, sloppy work. However, an issue is always a good reminder. ;)
Here comes the enhanced version for D8 and D7 as well as tests.
D8-pager-QueryExtender-fix-1857048-2-test-only.patchexpected to fail as it only contains the tests without the fix.D7-pager-QueryExtender-fix-1857048-2-do-not-test.patchcontains the fix as well as the new test.Comment #4
das-peter commentedOh I missed the fact that entity query makes its own thing when using the method
pager(). Patches adjusted.Same as before the
test-onlypatch is expected to fail.D7 patch locally passes the, so far, relevant tests.
Comment #6
dawehnerAfter some discussion we came to the conclusion that the pager ID should be injected, so basically the other way round.
I think we musn't use t() functions on new assertion messages.
Comment #7
das-peter commentedAs mentioned by Daniel here comes a solution the other way around.
Less code changes more test assertions.
But for now only for D8, if approach is approved I'll create the related D7 patch.
Comment #8
dawehnerThis is way better then before!
This seems to be everything you could test.
Comment #9
das-peter commentedAs waving with my hands won't be enough to get attention, I move this to a more popular component :D
Comment #10
das-peter commented7: D8-pager-QueryExtender-fix-1857048-7.patch queued for re-testing.
Comment #22
larowlanComment #23
quietone commentedAdd tag.
Comment #24
karishmaamin commentedRe-rolled patch against 9.4.x
Comment #25
ankithashettyFixed custom command errors and updated deprecated codes, thanks!
Comment #26
ankithashettyAttaching a valid interdiff file, thanks!
Comment #30
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.