Brad Jorsch schreef:
On Tue, Feb 10, 2009 at 10:14:38PM +0100, Roan Kattouw wrote:
Implemented something similar to your suggestion in r47108.
Note there's no need for asort in this one, asort is only needed when you want to keep the array keys.
Oops, meant ksort(). You can't really sort Title objects :P , but the keys are page IDs.
I suppose if you want to be tricky, you could do something like this: sort($titles);
for ( $i = count($titles) - 1; $i >= 0 && $titles[$i] >= $fromTitle; $i-- ); $titles = array_slice($titles, $i); but I don't know if it would really gain you much.
No, I only did it in imageinfo so the FileRepo wouldn't be queried for stuff we're gonna throw away right after. For prop=info, there's no gain in doing this over something like if($title < $contTitle) continue;
BTW, it looks like any missing images could be returned for all queries now. Consider if there are 4 images: three have huge numbers of revisions, and the last one does not exist.
- The first query will include image1, decide image2 is too big, and then tack on image4 (0 size).
- The second query will skip image1, include image2, decide image3 is too big, and then tack on image4 again (0 size).
- The third query will skip image1 and image2, include image3, and tack on image4 yet again (0 size).
I suppose the quick fix is to skip all missing images if continue is set, since all missing images will always be included in the first query.
I don't see how that's a problem. The <page> element for the missing image is always gonna be there (hell, it's even there for images that are already done and skipped thanks to iicontinue), it just has an extra missing="" filerepo="" thingy on it. Don't see much of a problem there.
prop=info could be done by merging $titles and $missing (if necessary), doing an asort, and using similar logic. The continue would be just the title.
I'll look into that tomorrow as well.
On second thought, I don't think we need it: prop=info doesn't have the issues other modules have, because it doesn't return multiple entries per page. Just throwing in an asort() (which I'll do tomorrow) should suffice.
If you're removing the continuation (as you did for missing images above) then you don't even need to asort if you don't want to. If you're keeping continuation, though, then both existing and missing pages could trigger a continuation so you really would need the merge (otherwise consider what happens if titles=A|Bdoesnotexist|C|D|E|F, D triggers a continuation, and Bdoesnotexist also doesn't fit after).
Actually I wouldn't need to merge them: I'll just do all existing pages first, then all missing ones (this already happens), and sort those arrays separately. The offset continue thing will work just fine.
BTW, I just noticed prop=info is broken for missing pages if it decides to continue in the middle of one, in that it will give you partial results that could easily break program logic. It should really be all-or-none like it is for non-missing pages. That should also fix the bug I just discovered where it crashes with a PHP fatal error when trying to get a token for a missing page.
Yeah, that's probably a good point. Will fix that tomorrow.
Roan Kattouw (Catrope)