FileCache - Leave raw page cache control alone to avoid hits
[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-2008 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
37
38 # Initialise common code
39 $preIP = dirname( __FILE__ );
40 require_once( "$preIP/includes/WebStart.php" );
41
42 # Initialize MediaWiki base class
43 require_once( "$preIP/includes/Wiki.php" );
44 $mediaWiki = new MediaWiki();
45
46 wfProfileIn( 'main-misc-setup' );
47 OutputPage::setEncodings(); # Not really used yet
48
49 $maxLag = $wgRequest->getVal( 'maxlag' );
50 if( !is_null($maxLag) && !$mediaWiki->checkMaxLag( $maxLag ) ) {
51 exit;
52 }
53
54 # Query string fields
55 $action = $wgRequest->getVal( 'action', 'view' );
56 $title = $wgRequest->getVal( 'title' );
57
58 $wgTitle = $mediaWiki->checkInitialQueries( $title, $action );
59 if( $wgTitle === NULL ) {
60 unset( $wgTitle );
61 }
62
63 wfProfileOut( 'main-misc-setup' );
64
65 #
66 # Send Ajax requests to the Ajax dispatcher.
67 #
68 if( $wgUseAjax && $action == 'ajax' ) {
69 require_once( $IP . '/includes/AjaxDispatcher.php' );
70 $dispatcher = new AjaxDispatcher();
71 $dispatcher->performAction();
72 $mediaWiki->restInPeace();
73 exit;
74 }
75
76 if( $wgUseFileCache && isset($wgTitle) ) {
77 wfProfileIn( 'main-try-filecache' );
78 // Raw pages should handle control on their own
79 // even when using file cache.
80 if( $action != 'raw' && HTMLFileCache::useFileCache() ) {
81 /* Try low-level file cache hit */
82 $cache = new HTMLFileCache( $wgTitle, $action );
83 if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
84 /* Check incoming headers to see if client has this cached */
85 if( !$wgOut->checkLastModified( $cache->fileCacheTime() ) ) {
86 $cache->loadFromFileCache();
87 }
88 # Do any stats increment/watchlist stuff
89 $wgArticle = MediaWiki::articleFromTitle( $wgTitle );
90 $wgArticle->viewUpdates();
91 # Tell $wgOut that output is taken care of
92 wfProfileOut( 'main-try-filecache' );
93 $mediaWiki->restInPeace();
94 exit;
95 }
96 }
97 wfProfileOut( 'main-try-filecache' );
98 }
99
100 # Setting global variables in mediaWiki
101 $mediaWiki->setVal( 'action', $action );
102 $mediaWiki->setVal( 'CommandLineMode', $wgCommandLineMode );
103 $mediaWiki->setVal( 'DisabledActions', $wgDisabledActions );
104 $mediaWiki->setVal( 'DisableHardRedirects', $wgDisableHardRedirects );
105 $mediaWiki->setVal( 'DisableInternalSearch', $wgDisableInternalSearch );
106 $mediaWiki->setVal( 'EnableCreativeCommonsRdf', $wgEnableCreativeCommonsRdf );
107 $mediaWiki->setVal( 'EnableDublinCoreRdf', $wgEnableDublinCoreRdf );
108 $mediaWiki->setVal( 'JobRunRate', $wgJobRunRate );
109 $mediaWiki->setVal( 'Server', $wgServer );
110 $mediaWiki->setVal( 'SquidMaxage', $wgSquidMaxage );
111 $mediaWiki->setVal( 'UseExternalEditor', $wgUseExternalEditor );
112 $mediaWiki->setVal( 'UsePathInfo', $wgUsePathInfo );
113
114 $mediaWiki->initialize( $wgTitle, $wgArticle, $wgOut, $wgUser, $wgRequest );
115 $mediaWiki->finalCleanup( $wgDeferredUpdateList, $wgOut );
116
117 # Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
118 $mediaWiki->doUpdates( $wgPostCommitUpdateList );
119
120 $mediaWiki->restInPeace();
121