Also set the queue types map when rebuilding the ready queue map
[lhc/web/wiklou.git] / includes / WebStart.php
1 <?php
2 /**
3 * This does the initial set up for a web request.
4 * It does some security checks, starts the profiler and loads the
5 * configuration, and optionally loads Setup.php depending on whether
6 * MW_NO_SETUP is defined.
7 *
8 * Setup.php (if loaded) then sets up GlobalFunctions, the AutoLoader,
9 * and the configuration globals (though not $wgTitle).
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 * http://www.gnu.org/copyleft/gpl.html
25 *
26 * @file
27 */
28
29 # Protect against register_globals
30 # This must be done before any globals are set by the code
31 if ( ini_get( 'register_globals' ) ) {
32 if ( isset( $_REQUEST['GLOBALS'] ) || isset( $_FILES['GLOBALS'] ) ) {
33 die( '<a href="http://www.hardened-php.net/globals-problem">'
34 . '$GLOBALS overwrite vulnerability</a>' );
35 }
36
37 $verboten = array(
38 'GLOBALS',
39 '_SERVER',
40 'HTTP_SERVER_VARS',
41 '_GET',
42 'HTTP_GET_VARS',
43 '_POST',
44 'HTTP_POST_VARS',
45 '_COOKIE',
46 'HTTP_COOKIE_VARS',
47 '_FILES',
48 'HTTP_POST_FILES',
49 '_ENV',
50 'HTTP_ENV_VARS',
51 '_REQUEST',
52 '_SESSION',
53 'HTTP_SESSION_VARS'
54 );
55
56 foreach ( $_REQUEST as $name => $value ) {
57 if ( in_array( $name, $verboten ) ) {
58 header( "HTTP/1.1 500 Internal Server Error" );
59 echo "register_globals security paranoia: trying to overwrite superglobals, aborting.";
60 die( -1 );
61 }
62 unset( $GLOBALS[$name] );
63 }
64 }
65
66 # bug 15461: Make IE8 turn off content sniffing. Everybody else should ignore this
67 # We're adding it here so that it's *always* set, even for alternate entry
68 # points and when $wgOut gets disabled or overridden.
69 header( 'X-Content-Type-Options: nosniff' );
70
71 $wgRequestTime = microtime( true );
72 # getrusage() does not exist on the Microsoft Windows platforms, catching this
73 if ( function_exists ( 'getrusage' ) ) {
74 $wgRUstart = getrusage();
75 } else {
76 $wgRUstart = array();
77 }
78 unset( $IP );
79
80 # Valid web server entry point, enable includes.
81 # Please don't move this line to includes/Defines.php. This line essentially
82 # defines a valid entry point. If you put it in includes/Defines.php, then
83 # any script that includes it becomes an entry point, thereby defeating
84 # its purpose.
85 define( 'MEDIAWIKI', true );
86
87 # Full path to working directory.
88 # Makes it possible to for example to have effective exclude path in apc.
89 # __DIR__ breaks symlinked includes, but realpath() returns false
90 # if we don't have permissions on parent directories.
91 $IP = getenv( 'MW_INSTALL_PATH' );
92 if ( $IP === false ) {
93 if ( realpath( '.' ) ) {
94 $IP = realpath( '.' );
95 } else {
96 $IP = dirname( __DIR__ );
97 }
98 }
99
100 # Start the autoloader, so that extensions can derive classes from core files
101 require_once "$IP/includes/AutoLoader.php";
102
103 # Load the profiler
104 require_once "$IP/includes/profiler/Profiler.php";
105
106 # Load up some global defines.
107 require_once "$IP/includes/Defines.php";
108
109 # Start the profiler
110 $wgProfiler = array();
111 if ( file_exists( "$IP/StartProfiler.php" ) ) {
112 require "$IP/StartProfiler.php";
113 }
114
115 wfProfileIn( 'WebStart.php-conf' );
116
117 # Load default settings
118 require_once "$IP/includes/DefaultSettings.php";
119
120 # Load composer's autoloader if present
121 if ( is_readable( "$IP/vendor/autoload.php" ) ) {
122 require_once "$IP/vendor/autoload.php";
123 }
124
125 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
126 # Use a callback function to configure MediaWiki
127 call_user_func( MW_CONFIG_CALLBACK );
128 } else {
129 if ( !defined( 'MW_CONFIG_FILE' ) ) {
130 define( 'MW_CONFIG_FILE', "$IP/LocalSettings.php" );
131 }
132
133 # LocalSettings.php is the per site customization file. If it does not exist
134 # the wiki installer needs to be launched or the generated file uploaded to
135 # the root wiki directory. Give a hint, if it is not readable by the server.
136 if ( !is_readable( MW_CONFIG_FILE ) ) {
137 require_once "$IP/includes/templates/NoLocalSettings.php";
138 die();
139 }
140
141 # Include site settings. $IP may be changed (hopefully before the AutoLoader is invoked)
142 require_once MW_CONFIG_FILE;
143 }
144
145 wfProfileOut( 'WebStart.php-conf' );
146
147 wfProfileIn( 'WebStart.php-ob_start' );
148 # Initialise output buffering
149 # Check that there is no previous output or previously set up buffers, because
150 # that would cause us to potentially mix gzip and non-gzip output, creating a
151 # big mess.
152 if ( !defined( 'MW_NO_OUTPUT_BUFFER' ) && ob_get_level() == 0 ) {
153 require_once "$IP/includes/OutputHandler.php";
154 ob_start( 'wfOutputHandler' );
155 }
156 wfProfileOut( 'WebStart.php-ob_start' );
157
158 if ( !defined( 'MW_NO_SETUP' ) ) {
159 require_once "$IP/includes/Setup.php";
160 }