Brad Jorsch schreef:
On Tue, Feb 10, 2009 at 11:24:51PM +0100, Roan Kattouw
wrote:
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.
$titles isn't title objects there, though. It's the keys off of
$pageIds[NS_FILE], which seems to be page title strings.
Yeah, you can either do array_keys() then sort(), or ksort() then
array_keys(). I seem to have thought the other way.
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.
Will it really?
** First query:
1. You'll process 'A' for the output.
2. You'll process 'C' for the output.
3. You'll try to process 'D' for the output, but it will fail for being
too big. You'll set incontinue=2.
4. You may or may not try to process 'Bdoesnotexist'. If so, it fails
too. Do you set incontinue=0 now? Or leave it as 2?
The continue parameter can
never be set twice; trying to do that throws
a fatal error. I added a guard against processing missing pages when the
existing pages didn't fit in my working copy, which I'll commit today.
And you don't set incontinue=0 in this case, but incontinue=3 (because
$count isn't reset).
** Someone creates Bdoesnotexist.
Yes, that
sucks. I'm still thinking about how to handle this best
(because creating a page could cause another page to be skipped entirely).
** Second query: (incontinue=2)
1. You'll skip 'A', because 0<2.
2. You'll skip the newly created 'Bdoesnotexist', because 1<2. (oops!)
3. You'll process 'C' for the output, again. (oops!)
4. You'll process 'D' for the output.
5. You'll process 'E' for the output.
6. You'll process 'F' for the output.
** Alternate second query: (incontinue=0)
1. You'll process 'A' for the output, because 0 is not < 0. (oops!)
2. You'll process 'C' for the output. (oops!)
3. You'll try to process 'D' for the output, but it will fail for being
too big. You'll set incontinue=2.
4. You try to process 'Bdoesnotexist'. It fails too. You set
incontinue=0 again. Lather, rinse, repeat. (oops!)
This one won't happen
(see above).
** First query:
1. You'll process 'A' for the output.
2. You'll process 'C' for the output.
3. You'll try to process 'D' for the output, but it will fail for being
too big. You'll set incontinue=2.
4. You may or may not try to process 'Bdoesnotexist'. If so, it fails
too. Do you set incontinue=0 now? Or leave it as 2?
** Someone deletes A.
Yes, like I said above, page creations can cause trouble
too.
Roan Kattouw (Catrope)