Call finalCleanup() after outputting a cached page to run the deferred update list...
[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-2010 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 and others.
20 *
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 2 of the License, or
24 * (at your option) any later version.
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * You should have received a copy of the GNU General Public License along
32 * with this program; if not, write to the Free Software Foundation, Inc.,
33 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
34 * http://www.gnu.org/copyleft/gpl.html
35 *
36 * @file
37 */
38
39 # Initialise common code
40 $preIP = dirname( __FILE__ );
41 require_once( "$preIP/includes/WebStart.php" );
42
43 # Initialize MediaWiki base class
44 $mediaWiki = new MediaWiki();
45
46 wfProfileIn( 'main-misc-setup' );
47
48 $maxLag = $wgRequest->getVal( 'maxlag' );
49 if( !is_null( $maxLag ) && !$mediaWiki->checkMaxLag( $maxLag ) ) {
50 exit;
51 }
52
53 # Query string fields
54 $action = $wgRequest->getVal( 'action', 'view' );
55 $title = $wgRequest->getVal( 'title' );
56
57 # Set title from request parameters
58 $wgTitle = $mediaWiki->checkInitialQueries( $title, $action );
59
60 wfProfileOut( 'main-misc-setup' );
61
62 # Send Ajax requests to the Ajax dispatcher.
63 if( $wgUseAjax && $action == 'ajax' ) {
64 $dispatcher = new AjaxDispatcher();
65 $dispatcher->performAction();
66 $mediaWiki->restInPeace();
67 exit;
68 }
69
70 if( $wgUseFileCache && $wgTitle !== null ) {
71 wfProfileIn( 'main-try-filecache' );
72 // Raw pages should handle cache control on their own,
73 // even when using file cache. This reduces hits from clients.
74 if( $action != 'raw' && HTMLFileCache::useFileCache() ) {
75 /* Try low-level file cache hit */
76 $cache = new HTMLFileCache( $wgTitle, $action );
77 if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
78 /* Check incoming headers to see if client has this cached */
79 if( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) {
80 $cache->loadFromFileCache();
81 }
82 # Do any stats increment/watchlist stuff
83 $wgArticle = MediaWiki::articleFromTitle( $wgTitle );
84 $wgArticle->viewUpdates();
85 # Tell $wgOut that output is taken care of
86 $wgOut->disable();
87 wfProfileOut( 'main-try-filecache' );
88 $mediaWiki->finalCleanup( $wgOut );
89 $mediaWiki->restInPeace();
90 exit;
91 }
92 }
93 wfProfileOut( 'main-try-filecache' );
94 }
95
96 # Setting global variables in mediaWiki
97 $mediaWiki->setVal( 'action', $action );
98 $mediaWiki->setVal( 'DisabledActions', $wgDisabledActions );
99 $mediaWiki->setVal( 'DisableHardRedirects', $wgDisableHardRedirects );
100 $mediaWiki->setVal( 'EnableCreativeCommonsRdf', $wgEnableCreativeCommonsRdf );
101 $mediaWiki->setVal( 'EnableDublinCoreRdf', $wgEnableDublinCoreRdf );
102 $mediaWiki->setVal( 'Server', $wgServer );
103 $mediaWiki->setVal( 'SquidMaxage', $wgSquidMaxage );
104 $mediaWiki->setVal( 'UseExternalEditor', $wgUseExternalEditor );
105 $mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo );
106
107 $mediaWiki->performRequestForTitle( $wgTitle, $wgArticle, $wgOut, $wgUser, $wgRequest );
108 $mediaWiki->finalCleanup( $wgOut );
109 $mediaWiki->restInPeace();