[Mediawiki-l] [quickhack] require a specific user to view a page

Rowan Collins rowan.collins at gmail.com
Wed Feb 2 21:36:57 UTC 2005

On Wed, 2 Feb 2005 20:42:10 +0100, Moritz Karbach <mailinglist at karba.ch> wrote:
> first of all thanks for analyzing my code :-)

No problem - in fact, sorry for picking it apart to such an extent.
> > Firstly, it allows any user to lock themselves
> That's one thing I can tolerate.

Funny, I figured that would be the worst part. But I guess if you've
got total control over who has editing rights anyway (a CMS-style
environment, rather than a truly wiki-ish one), this isn't such a big
deal after all.
> > Secondly, the content can be viewed by using the "preview" function:
> But this I'd like to fix!
> I guess it would be best to include some check after the page has been parsed,
> but before it gets displayed. If there is a function that gathers the
> categories (from db and from preview) and passes them to the parser, this
> would be perfect.

I'm pretty sure it's the other way around - the "parser" has to go
through the wikitext, and pick out any category links it finds; these
are then plonked in the database for other use if the page is being
saved. On preview, they're just added in the little box at the bottom
of the page, without the database being updated.

But that doesn't remove the potential for grabbing a list of them -
Skin.php has a function called getCategoryLinks(), which grabs the
definitive list of categories from $wgOut (the instance of
OutputPage.php). If you were to use one of those as your source, I
think [although I wouldn't guarantee] you would get the categories
currently included on the page, even in preview, irrespective of
what's in the database.

It does mean, though, that you'll need to do the check *right at the
end* of the parsing - somewhere just before the HTML is actually
output, but after the wikitext has been parsed from beginning to end.

> Is there some dataflow chart or something on the web, where the parsing
> mechanism is explained?

Hm, I believe you have just run into "Bug 1"
[http://bugzilla.wikipedia.org/show_bug.cgi?id=1]. In other words, no,
not that I've ever seen. The codebase, particularly the parsing and
associated processing, is somewhat labyrinthine, I'm afraid - all done
through a complex tangle of Parser.php (don't be fooled, it's not so
much a parser as a bunch of loops and regexes), Skin.php (and its
sub-classes) and OutputPage.php.

There is some automatically generated [from source comments]
documentation at http://wikipedia.sourceforge.net/docs/html/ -
although this seems to be out of date right now. There's also a few
fragments on the meta wiki, like
http://meta.wikimedia.org/wiki/MediaWiki_code_layout, for very general

Rowan Collins BSc

More information about the MediaWiki-l mailing list