User:Lilyuserin/Digging deeper

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Abtauchen in die Tiefen der MediaWiki-Software

Vor einem halben Jahr habe ich mein erstes Wiki aufgesetzt (das ich hier nicht verlinke, weil ich den Webspace kündigen werde), von der Wiki-Syntax hatte ich kaum eine Ahnung. Inzwischen hat sich diese Userinnenseite zu einer Art Tagebuch meiner Erkenntnisse bzgl. Administration eines Wikis entwickelt, vor drei Monaten (zum Zeitpunkt der Entstehung dieses Textes) habe ich begonnen, hier (zunächst auf einem anderen Account) mein Wissen über die MW-Software zu sammeln.

Datenbankstruktur

[edit]

MediaWiki Software-Architektur

[edit]

Vor einiger Zeit hat es ein Projekt zur Dokumentation der MediaWiki Architektur gegeben, hier das Ergebnis: Manual:MediaWiki architecture

Ich zitiere:

Execution workflow of a web request

[edit]

index.php is the main access point for MediaWiki, and handles most requests processed by the application servers (i.e. requests that were not served by the caching infrastructure). The code executed from index.php performs security checks, loads default configuration settings from includes/DefaultSettings.php, guesses configuration with includes/Setup.php and then applies site settings contained in LocalSettings.php. It then instantiates a MediaWiki object ($mediawiki), and creates a Title object $wgTitle depending on the title and action parameters from the request.

index.php can take a variety of action parameters in the URL request; the default action is view, which shows the regular view of an article's content. For example, the request https://en.wikipedia.org/w/index.php?title=Apple&action=view displays the content of the article "Apple" on the English Wikipedia. Other frequent actions include edit (to open an article for editing), submit (to preview or save an article), history (to show an article's history) and watch (to add an article to the user's watchlist). Administrative actions include delete (to delete an article) and protect (to prevent edits to an article).

MediaWiki::performRequest() is then called to handle most of the URL request. It checks for bad titles, read restrictions, local interwiki redirects, and redirect loops, and determines whether the request is for a normal or a special page.

Normal page requests are handed over to MediaWiki::initializeArticle(), to create an Article object for the page ($wgArticle), and then to MediaWiki::performAction(), which handles "standard" actions. Once the action has been completed, MediaWiki::finalCleanup() finalizes the request by committing DB transactions, outputting the HTML and launching deferred updates through the job queue. MediaWiki::restInPeace() commits the deferred updates and closes the task gracefully.

If the page requested is a Special page (i.e., not a regular wiki content page, but a special software-related page such as Statistics), SpecialPageFactory::executePath is called instead of initializeArticle(); the corresponding PHP script is then called. Special pages can do all sorts of magical things, and each has a specific purpose, usually independent of any one article or its content. Special pages include various kinds of reports (recent changes, logs, uncategorized pages) and wiki administration tools (user blocks, user rights changes), among others. Their execution workflow depends on their function.

Many functions contain profiling code, which makes it possible to follow the execution workflow for debugging, if profiling is enabled. Profiling is done by calling the wfProfileIn and wfProfileOut functions to respectively start and stop profiling a function; both functions take the function's name as a parameter. On Wikimedia sites, profiling is done for a percentage of all requests, to preserve performance. MediaWiki sends UDP packets to a central server that collects them and produces profiling data.

index.php

[edit]

Der zentrale Einstiegspunkt in das Wiki.

includes/DefaultSettings.php

[edit]

Dokumentation auf GitHub

includes/Setup.php

[edit]

SourceCode auf GitHub

GitHub

[edit]

GitHub ist der zentrale Angelpunkt der Open-Source Entwickler, ein zunächst undurchschaubares System, mit dem ich mich nicht weiter beschäftigen werde. Die MediaWiki-Software wird auf GitHub gehostet, daher sind hier die originalen Dokumentationen zu finden.

In zwangloser Reihenfolge ein paar Links.

Von hier ausgehend kannst du dich durch die Tiefen der MediaWiki-Software hanteln. Falls ich einen besonders interessanten oder für mich wichtigen Link finde, werde ich die Liste erweitern.

Magic Words

[edit]

Definition der Magic Words auf GitHub

MagicWord Array auf GitHub

Magic Words Help

Manual Magic Words

Ich übersetze mal vom Manual. Die Bezeichnung Magic Word lasse ich unverändert, da mir die wörtliche deutsche Übersetzung nicht gefällt.

Mit Magic Word werden Zeichenketten in einer Wikiseite einer eindeutigen ID zugeordnet, die mit einer Funktion verknüpft ist. Sowohl Variable als auch Parser Funktionen benutzen diese Technik. Der Text, der dieser ID zugeordnet wird, wird durch den Rückgabewert einer Funktion ersetzt. Mit anderen Worten, der Text wird durch eine Funktion ersetzt, was irgendwie klar ist, wenn man sich die derzeit existierenden Magic Words anschaut.

Die Standard Magic Words sind in der Datei CoreParserFunctions.php definiert. Diese befindet sich um Unterverzeichnis parser des Include-Verzeichnisses.

Wenn MediaWiki Text zwischen zwei geschweiften Doppelklammern findet ({{XXX ...}}), muss es entscheiden, ob es sich um eine Variable, eine Parser-Funktion oder um eine Vorlage handelt. Zu diesem Zweck muss eine Reihe von Fragen geklärt werden.

Existiert eine Magic Word ID? Zunächst versucht MediaWiki, XXX in eine Magic Word ID zu übersetzen. Die Übersetzungstabelle ist durch $magicWords definiert.

Variable im Handbuch von MediaWiki sind nichts anderes als die Magic Words, praktisch fix verdrahtete Vorlagen ohne Parameter. Man kann eigene Magic Words definieren.