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.
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.
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.
1. The first query will include image1, decide image2 is too big, and
then tack on image4 (0 size).
2. The second query will skip image1, include image2, decide image3 is
too big, and then tack on image4 again (0 size).
3. 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.
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).
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.