Steve Bennett wrote:
On 8/21/06, Gregory Maxwell gmaxwell@gmail.com wrote:
Surprised that you didn't name this one, since it is one of the more useful human oriented ones (and a primary application for the living people cat):
e) Produce a filtered recent changes feed (http://en.wikipedia.org/w/index.php?title=Special:Recentchangeslinked&ta...)
Lots of these functionalities would be better if they handled subcategories, but for that to work we really need a better subcatting system. But I haven't got a solution yet.
Not wanting to suggest anything here, but I'll just throw something in that I came up with at work.
Essentially, I maintain a website that has "categories", and some features need to work for "this category and all its sub-categories". Since the category tree can theoretically grow arbitrarily, I figured that iterative queries ("cycling" through the sub-categories) is unacceptable, so instead I've done this:
* Create a new table, "CategoryTC" (TC = transitive closure) which has only two columns, "AncestorCID" and "CID" (CID = category ID). Each row in this table tells you that the category CID is somewhere below AncestorCID in the category tree. (For the pedants: It's actually the transitive-symmetric closure, i.e. every category is also its own ancestor.)
* In your SQL query, instead of some_variable=$cid you say some_variable=tc.CID and tc.AncestorCID=$cid or some_variable IN (select CID from CategoryTC where AncestorCID=$cid) and it works for sub-categories within the same query.
* When creating, deleting or re-parenting categories, obviously the transitive closure needs to be kept up to date. This is easier than it sounds.
* The CategoryTC table makes it absolutely trivial to prevent the creation of loops in the category tree.
The system would need some re-thinking for MediaWiki because in MediaWiki, the category structure is not a tree as it is in my case. In fact, MediaWiki's category structure isn't even acyclic, even though I'm pretty sure most people would agree that it should be acyclic and that the system should enforce acyclicity by rejecting edits that would create a category loop.
Timwi