This should fix a regression from my category sort work, caused by not
accounting for the the fact that $this->from and $this->until were
changed to arrays. Wrong counts for the number of pages in the category
might have been displayed in some cases.
Yeah, I kind of wish this was a joke. Granted, they're extremely fast
queries, and maybe they don't happen on all configs, but still. And I'm
still seeing 148 queries per view, mostly Revision::fetchFromConds() . . .
Three different extensions were copy-pasting all of
CategoryPage::closeShowCategory() just to change which CategoryViewer
descendant was used. I changed the base class to use a member variable
for the CategoryViewer class, so this reduces code duplication too. I
only tested this on CategoryTree; MetavidWiki is certainly still broken,
from the looks of it (assumes $this->from is a string), but
PeopleCategories might be okay. Hard to avoid breaking extensions with
this sort of schema/index change.
Patch best viewed with whitespace changes ignored. This will doubtless
introduce a bunch of bugs. Please report any so I can fix them. If
they're big enough and the fix isn't obvious, please revert.
Deprecate makeSizeLinkObj. The only usage is in CategoryPage, which we can change to link() without penalty, since the created Title is already loaded with its length.
As Bawolff pointed out at [[mw:User talk:Simetrical/Collation]], the
prefixing scheme I was using meant that the page "Z" with sort key of
"F" would sort after a page named "A" with a sort key of "FF", since the
first one's raw sort key would compute to "FZ", and the second's would
compute to "FFA". I've fixed this by separating the prefix from the
unprefixed part by a null byte (cl_sortkey is eventually going to be
totally binary anyway, may as well start now).
This fully fixes bug 1211. It might be buggy, and
$wgExperimentalCategorySort sure makes it hackish. I should definitely
have gone with some kind of branch here. More testing would be good.
Also, the UI could use improvement (extra ugly next/previous 200 links
in various places).
In response to feedback by Phillipe Verdy on bug 164. Now if a bunch of
pages have [[Category:Foo| ]], they'll sort amongst themselves according
to page name, instead of in basically random order as it is currently.
This also makes storage more elegant and intuitive: instead of giving
NULL a magic meaning when there's no custom sortkey specified, we just
store an empty string, since there's no prefix.
This means {{defaultsort:}} really now means {{defaultsortprefix:}},
which is slightly confusing, and a lot of code is now slightly
misleading or poorly named. But it should all work fine.
Also, while I was at it, I made updateCollation.php work as a transition
script, so you can apply the SQL patch and then run updateCollation.php
and things will work. However, with the new schema it's not trivial to
reverse this -- you'd have to recover the raw sort keys with some PHP.
Conversion goes at about a thousand rows a second for me, and seems to
be CPU-bound. Could probably be optimized.
I also adjusted the transition script so it will fix rows with collation
versions *greater* than the current one, as well as less. Thus if some
site wants to use their own collation, they can call it 137 or
something, and if they later want to switch back to MediaWiki stock
collation 7, it will work.
Also fixed a silly bug in updateCollation.php where it would say "1000
done" if it did nothing, and changed $res->numRows() >= self::BATCH_SIZE
to == so people don't wonder how it could be bigger (since it can't, I
hope).
It seemed to work correctly, with the newly-created page "bob" sorting
as "BOB", but then I nuked all my cl_sortkey by running the migration
script before refreshLinks.php had finished running, so I'll have to
wait a while to see if it works properly with a non-messed-up database.
It's possible there's something wrong with the display of section
letters in the categories, but otherwise I think this is working right.
Hidden behind $wgExperimentalCategorySort until it's reasonably
complete. If that's false, no behavior should change (but I didn't test
carefully, so poke me if there's a bug). See DefaultSettings.php for
documentation on setting it to true. Currently you should not do this
except if you're working on the feature, since functionality is not
close to reasonable yet and will change rapidly.
Bug 1211 is already fixed with this commit for me. However, many other
things still need to be done, so this is all very much a
proof-of-concept.
Cannot know if completely suppressing this is possible (and show 'category-empty'), because 'until' or 'from' can be set and previous/next *may* give results). Adding a FIXME for that.
r46020 added a call to $wgContLang->convert() for category article listings, but mistakenly passed the title *object* instead of the text.
In PHP 5.2, this was silently converted to a string, but in older versions this would interpolate as something useless like "Object id #110".