Store the WebRequest and OutputPage in the MediaWiki class, don't pass the global...
[lhc/web/wiklou.git] / index.php
1 <?php
2
3 /**
4 * This is the main web entry point for MediaWiki.
5 *
6 * If you are reading this in your web browser, your server is probably
7 * not configured correctly to run PHP applications!
8 *
9 * See the README, INSTALL, and UPGRADE files for basic setup instructions
10 * and pointers to the online documentation.
11 *
12 * http://www.mediawiki.org/
13 *
14 * ----------
15 *
16 * Copyright (C) 2001-2011 Magnus Manske, Brion Vibber, Lee Daniel Crocker,
17 * Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason,
18 * Niklas Laxström, Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor,
19 * Aaron Schulz, Andrew Garrett, Raimond Spekking, Alexandre Emsenhuber
20 * Siebrand Mazeland, Chad Horohoe, Roan Kattouw and others.
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License along
33 * with this program; if not, write to the Free Software Foundation, Inc.,
34 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
35 * http://www.gnu.org/copyleft/gpl.html
36 *
37 * @file
38 */
39
40 # Initialise common code
41 require ( dirname( __FILE__ ) . '/includes/WebStart.php' );
42
43 wfProfileIn( 'index.php' );
44 wfProfileIn( 'index.php-setup' );
45
46 # Initialize MediaWiki base class
47 $mediaWiki = new MediaWiki( $wgRequest, $wgOut );
48
49 $maxLag = $wgRequest->getVal( 'maxlag' );
50 if ( !is_null( $maxLag ) ) {
51 list( $host, $lag ) = wfGetLB()->getMaxLag();
52 if ( $lag > $maxLag ) {
53 wfMaxlagError( $host, $lag, $maxLag );
54 exit;
55 }
56 }
57
58 # Set title from request parameters
59 $wgTitle = $mediaWiki->checkInitialQueries();
60 $action = $wgRequest->getVal( 'action', 'view' );
61
62 wfProfileOut( 'index.php-setup' );
63
64 # Send Ajax requests to the Ajax dispatcher.
65 if ( $wgUseAjax && $action == 'ajax' ) {
66 $dispatcher = new AjaxDispatcher();
67 $dispatcher->performAction();
68 wfProfileOut( 'index.php' );
69 $mediaWiki->restInPeace();
70 exit;
71 }
72
73 if ( $wgUseFileCache && $wgTitle !== null ) {
74 wfProfileIn( 'index.php-filecache' );
75 // Raw pages should handle cache control on their own,
76 // even when using file cache. This reduces hits from clients.
77 if ( $action != 'raw' && HTMLFileCache::useFileCache() ) {
78 /* Try low-level file cache hit */
79 $cache = new HTMLFileCache( $wgTitle, $action );
80 if ( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
81 /* Check incoming headers to see if client has this cached */
82 if ( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) {
83 $cache->loadFromFileCache();
84 }
85 # Do any stats increment/watchlist stuff
86 $wgArticle = MediaWiki::articleFromTitle( $wgTitle );
87 $wgArticle->viewUpdates();
88 # Tell $wgOut that output is taken care of
89 $wgOut->disable();
90 wfProfileOut( 'index.php-filecache' );
91 $mediaWiki->finalCleanup();
92 wfProfileOut( 'index.php' );
93 $mediaWiki->restInPeace();
94 exit;
95 }
96 }
97 wfProfileOut( 'index.php-filecache' );
98 }
99
100 # Setting global variables in mediaWiki
101 $mediaWiki->setVal( 'DisableHardRedirects', $wgDisableHardRedirects );
102 $mediaWiki->setVal( 'EnableCreativeCommonsRdf', $wgEnableCreativeCommonsRdf );
103 $mediaWiki->setVal( 'EnableDublinCoreRdf', $wgEnableDublinCoreRdf );
104 $mediaWiki->setVal( 'Server', $wgServer );
105 $mediaWiki->setVal( 'SquidMaxage', $wgSquidMaxage );
106 $mediaWiki->setVal( 'UseExternalEditor', $wgUseExternalEditor );
107 $mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo );
108
109 $mediaWiki->performRequestForTitle( $wgTitle, $wgArticle, $wgUser );
110 $mediaWiki->finalCleanup();
111
112 wfProfileOut( 'index.php' );
113
114 $mediaWiki->restInPeace();