Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Dec 2009 at 04:28 UTC
Updated:
18 Aug 2010 at 03:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
pwolanin commentedmotivation is this issue for apachesolr in D6: #667110: Replace bogus use of pager_query()
Should be a simple cut-n-paste patch moving code within pager.inc and wrapping some of it in a public API function. Let's see if this is working in all tests.
Comment #2
catchPatch looks good, let's see what the test bot says.
Comment #4
pwolanin commentedoops - forgot to move the global variabl declarations.
Comment #7
pwolanin commentedodd - those fails relate to filefield and not anything in the pager. Probably false.
Comment #9
pwolanin commentedI don't see this failure locally - wth?
Comment #11
agentrickardI think the patch is ok; testbot was glitchy. I'm seeing fails locally, but I don't think they are related to this patch.
Comment #12
moshe weitzman commentedHmmm. Perhaps rename to pager_default_initialize since we deliberately left the door open in D7 to alternate pager classes.
Comment #13
pwolanin commentedrenamed function
Comment #14
agentrickardPatch applies and works. Might be nice to add some docblock comments about how to add a custom pager.
Comment #15
webchickYes, let's get some how-to PHPDoc in here before this is committed.
Also, is there any particular reason we don't just make this part of the constructor of PagerDefault? Then PagerSuperAwesome could just do a similar thing in its constructor.
Comment #16
cburschkaA few minor quibbles about comments, and one about code flow:
"found" is kind of jarring here, since we're talking about items in general, not search results.
Who is "you"? The code, the server or the developer? ;)
It's no real performance overhead, but do you really need to re-populate the global variable on every call? Just do it once or something...
This review is powered by Dreditor.
Comment #17
pwolanin commented@webchick
we have to execute a query:
so I don't think this is appropriate for the constructor.
Comment #18
cburschkaWell, PagerDefault is a class because it extends PDO. If we conclude that all pagers should be classes, then what would "PagerWithoutDatabase" extend? It can't exactly extend the SelectQueryExtender like PagerDefault does. (Nor can we make both extend a common Pager class, since that would involve PagerDefault extending two classes.)
In fact, the "PagerWithoutDatabase" pager would be completely unrelated to the database part, so I'm not sure why it should be a class.
Comment #19
pwolanin commentedRight, that's why I rolled this patch - for pagers that are totally unrelated ot the database.
I think what webchick meant (???) was an alternate DB pager class should inherit as much as possible. But I think this patch helps that too, since it reduces the # of LOC that might have to be reproduced in a variant implementation.
Comment #20
pwolanin commentedI've broken this out into a second helper function (see the code examples) and added 2x code examples in the doxygen. I'm not sure what format we are using in D7 for these - there is no real use case in core, so the code is hypothetical.
Comment #22
pwolanin commentedoops rolled patch with the wrong options
Comment #23
MichaelCole commented#22: pager-init-667112-22.patch queued for re-testing.
Comment #24
pwolanin commentedThis patch now has the doxygen that was missing at #15 - back to rtbc?
Comment #25
HedgeMage commentedThis looks RTBC to me...thanks to webchick for prodding on the documentation, it was very much needed. :)
Comment #26
chx commentedOh my god what a useful patch, half of the very simplistic Views backends I wrote are repeatitions of this patch, yes, yes please do!
Comment #27
klausitrailing whitespace
Powered by Dreditor.
Comment #28
pwolanin commentedseems also patch doesn't apply cleanly. "Hunk #2 FAILED at 72."
Comment #29
pwolanin commentedLooks like just a whitespace change kept the patch from applying.
Comment #30
David_Rothstein commentedIn addition to the whitespace issues, the attached version:
Other than that, I've reviewed and tested this patch pretty carefully, and it's great. The actual code changes are pretty simple - mostly just moving existing code out into reusable functions - but the benefits are huge. In addition to Solr, the field API is another application in D7 where this is useful. Example: We are trying to build a D7 media gallery and want to page through the results of a multivalued media field on a node. We can't use the PagerDefault extender for that since field API queries are not tagged (and even if they were tagged, it wouldn't be a good idea, since the field API is supposed to be storage-agnostic).
This patch makes things work perfectly for that purpose, so hopefully we can get it in.
Comment #31
pwolanin commentedGiven that this has extra code comments and the only code changes from before are white space and removing the unneeded global, and all tests pass, I think this is back to RTBC.
Comment #32
chx commentedThis patch can't be committed. Really. What would happen to our cushy Drupal consultants jobs if we would make pager easy to use? Come on. First you remove the seven arguments of l() now it's pager globals? At this pace it won't take another 4-6 releases before any Dick or Harry can write Drupal code. We can't have that.
Comment #33
dries commentedCommitted to CVS HEAD. Thanks.