3 Globals are evil. The original MediaWiki code relied on
4 globals for processing context far too often. MediaWiki
5 development since then has been a story of slowly moving
6 context out of global variables and into objects. Storing
7 processing context in object member variables allows those
8 objects to be reused in a much more flexible way. Consider
11 # Generate the article HTML as if viewed by a web request
12 $article = new Article( Title::newFromText( $t ) );
17 # Save current globals
19 $oldArticle = $wgArticle;
22 $wgTitle = Title::newFromText( $t );
23 $wgArticle = new Article;
28 $wgArticle = $oldArticle
30 Some of the current MediaWiki developers have an idle
31 fantasy that some day, globals will be eliminated from
32 MediaWiki entirely, replaced by an application object which
33 would be passed to constructors. Whether that would be an
34 efficient, convenient solution remains to be seen, but
35 certainly PHP 5 makes such object-oriented programming
36 models easier than they were in previous versions.
38 For the time being though, MediaWiki programmers will have
39 to work in an environment with some global context. At the
40 time of writing, 418 globals were initialised on startup by
41 MediaWiki. 304 of these were configuration settings, which
42 are documented in DefaultSettings.php. There is no
43 comprehensive documentation for the remaining 114 globals,
44 however some of the most important ones are listed below.
45 They are typically initialised either in index.php or in
50 OutputPage object for HTTP response.
53 User object for the user associated with the current
57 Title object created from the request URL.
60 Language object selected by user preferences
63 Language object associated with the wiki being
67 Article object corresponding to $wgTitle.
70 Parser object. Parser extensions register their
74 A LoadBalancer object, manages database connections.