API: watchlist now reports a proper feed item when the user is not logged in. Also...
[lhc/web/wiklou.git] / includes / Setup.php
1 <?php
2 /**
3 * Include most things that's need to customize the site
4 */
5
6 /**
7 * This file is not a valid entry point, perform no further processing unless
8 * MEDIAWIKI is defined
9 */
10 if( !defined( 'MEDIAWIKI' ) ) {
11 echo "This file is part of MediaWiki, it is not a valid entry point.\n";
12 exit( 1 );
13 }
14
15 # The main wiki script and things like database
16 # conversion and maintenance scripts all share a
17 # common setup of including lots of classes and
18 # setting up a few globals.
19 #
20
21 $fname = 'Setup.php';
22 wfProfileIn( $fname );
23
24 // Check to see if we are at the file scope
25 if ( !isset( $wgVersion ) ) {
26 echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
27 die( 1 );
28 }
29
30 // Set various default paths sensibly...
31 if( $wgScript === false ) $wgScript = "$wgScriptPath/index.php";
32 if( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect.php";
33
34 if( $wgArticlePath === false ) {
35 if( $wgUsePathInfo ) {
36 $wgArticlePath = "$wgScript/$1";
37 } else {
38 $wgArticlePath = "$wgScript?title=$1";
39 }
40 }
41
42 if( $wgStylePath === false ) $wgStylePath = "$wgScriptPath/skins";
43 if( $wgStyleDirectory === false) $wgStyleDirectory = "$IP/skins";
44
45 if( $wgLogo === false ) $wgLogo = "$wgStylePath/common/images/wiki.png";
46
47 if( $wgUploadPath === false ) $wgUploadPath = "$wgScriptPath/images";
48 if( $wgUploadDirectory === false ) $wgUploadDirectory = "$IP/images";
49
50 if( $wgMathPath === false ) $wgMathPath = "{$wgUploadPath}/math";
51 if( $wgMathDirectory === false ) $wgMathDirectory = "{$wgUploadDirectory}/math";
52 if( $wgTmpDirectory === false ) $wgTmpDirectory = "{$wgUploadDirectory}/tmp";
53
54 if( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
55 if( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
56
57 require_once( "$IP/includes/AutoLoader.php" );
58
59 wfProfileIn( $fname.'-exception' );
60 require_once( "$IP/includes/Exception.php" );
61 wfInstallExceptionHandler();
62 wfProfileOut( $fname.'-exception' );
63
64 wfProfileIn( $fname.'-includes' );
65 require_once( "$IP/includes/GlobalFunctions.php" );
66 require_once( "$IP/includes/Hooks.php" );
67 require_once( "$IP/includes/Namespace.php" );
68 require_once( "$IP/includes/ProxyTools.php" );
69 require_once( "$IP/includes/ObjectCache.php" );
70 require_once( "$IP/includes/ImageFunctions.php" );
71 require_once( "$IP/includes/StubObject.php" );
72 wfProfileOut( $fname.'-includes' );
73 wfProfileIn( $fname.'-misc1' );
74
75
76 $wgIP = false; # Load on demand
77 # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
78 $wgRequest = new WebRequest;
79 if ( function_exists( 'posix_uname' ) ) {
80 $wguname = posix_uname();
81 $wgNodeName = $wguname['nodename'];
82 } else {
83 $wgNodeName = '';
84 }
85
86 # Useful debug output
87 if ( $wgCommandLineMode ) {
88 wfDebug( "\n\nStart command line script $self\n" );
89 } elseif ( function_exists( 'getallheaders' ) ) {
90 wfDebug( "\n\nStart request\n" );
91 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
92 $headers = getallheaders();
93 foreach ($headers as $name => $value) {
94 wfDebug( "$name: $value\n" );
95 }
96 wfDebug( "\n" );
97 } elseif( isset( $_SERVER['REQUEST_URI'] ) ) {
98 wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
99 }
100
101 if ( $wgSkipSkin ) {
102 $wgSkipSkins[] = $wgSkipSkin;
103 }
104
105 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
106
107 if($wgMetaNamespace === FALSE) {
108 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
109 }
110
111 # These are now the same, always
112 # To determine the user language, use $wgLang->getCode()
113 $wgContLanguageCode = $wgLanguageCode;
114
115 wfProfileOut( $fname.'-misc1' );
116 wfProfileIn( $fname.'-memcached' );
117
118 $wgMemc =& wfGetMainCache();
119 $messageMemc =& wfGetMessageCacheStorage();
120 $parserMemc =& wfGetParserCacheStorage();
121
122 wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
123 "\nMessage cache: " . get_class( $messageMemc ) .
124 "\nParser cache: " . get_class( $parserMemc ) . "\n" );
125
126 wfProfileOut( $fname.'-memcached' );
127 wfProfileIn( $fname.'-SetupSession' );
128
129 if ( $wgDBprefix ) {
130 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
131 } elseif ( $wgSharedDB ) {
132 $wgCookiePrefix = $wgSharedDB;
133 } else {
134 $wgCookiePrefix = $wgDBname;
135 }
136 $wgCookiePrefix = strtr($wgCookiePrefix, "=,; +.\"'\\[", "__________");
137
138 # If session.auto_start is there, we can't touch session name
139 #
140 if( !ini_get( 'session.auto_start' ) )
141 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
142
143 if( !$wgCommandLineMode && ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
144 wfIncrStats( 'request_with_session' );
145 wfSetupSession();
146 $wgSessionStarted = true;
147 } else {
148 wfIncrStats( 'request_without_session' );
149 $wgSessionStarted = false;
150 }
151
152 wfProfileOut( $fname.'-SetupSession' );
153 wfProfileIn( $fname.'-globals' );
154
155 if ( !$wgDBservers ) {
156 $wgDBservers = array(array(
157 'host' => $wgDBserver,
158 'user' => $wgDBuser,
159 'password' => $wgDBpassword,
160 'dbname' => $wgDBname,
161 'type' => $wgDBtype,
162 'load' => 1,
163 'flags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT
164 ));
165 }
166
167 $wgLoadBalancer = new StubObject( 'wgLoadBalancer', 'LoadBalancer',
168 array( $wgDBservers, false, $wgMasterWaitTimeout, true ) );
169 $wgContLang = new StubContLang;
170
171 // Now that variant lists may be available...
172 $wgRequest->interpolateTitle();
173
174 $wgUser = new StubUser;
175 $wgLang = new StubUserLang;
176 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
177 $wgParser = new StubObject( 'wgParser', 'Parser' );
178 $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
179 array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID() ) );
180
181 wfProfileOut( $fname.'-globals' );
182 wfProfileIn( $fname.'-User' );
183
184 # Skin setup functions
185 # Entries can be added to this variable during the inclusion
186 # of the extension file. Skins can then perform any necessary initialisation.
187 #
188 foreach ( $wgSkinExtensionFunctions as $func ) {
189 call_user_func( $func );
190 }
191
192 if( !is_object( $wgAuth ) ) {
193 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
194 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
195 }
196
197 wfProfileOut( $fname.'-User' );
198
199 wfProfileIn( $fname.'-misc2' );
200
201 $wgDeferredUpdateList = array();
202 $wgPostCommitUpdateList = array();
203
204 if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch';
205 if ( $wgAjaxWatch ) $wgAjaxExportList[] = 'wfAjaxWatch';
206
207 wfSeedRandom();
208
209 # Placeholders in case of DB error
210 $wgTitle = null;
211 $wgArticle = null;
212
213 wfProfileOut( $fname.'-misc2' );
214 wfProfileIn( $fname.'-extensions' );
215
216 # Extension setup functions for extensions other than skins
217 # Entries should be added to this variable during the inclusion
218 # of the extension file. This allows the extension to perform
219 # any necessary initialisation in the fully initialised environment
220 foreach ( $wgExtensionFunctions as $func ) {
221 $profName = $fname.'-extensions-'.strval( $func );
222 wfProfileIn( $profName );
223 call_user_func( $func );
224 wfProfileOut( $profName );
225 }
226
227 // For compatibility
228 wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
229 wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
230 wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
231 wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
232
233
234 wfDebug( "Fully initialised\n" );
235 $wgFullyInitialised = true;
236 wfProfileOut( $fname.'-extensions' );
237 wfProfileOut( $fname );
238
239 ?>