Use PHPUnit_Framework_TestCase in a few utils/ tests
[mediawiki.git] / includes / WebStart.php
blob217ba3fbd81e73e1d245a8d001edd557b7f7ebc9
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.
8 * Setup.php (if loaded) then sets up GlobalFunctions, the AutoLoader,
9 * and the configuration globals.
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.
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.
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
26 * @file
29 # Die if register_globals is enabled (PHP <=5.3)
30 # This must be done before any globals are set by the code
31 if ( ini_get( 'register_globals' ) ) {
32 die( 'MediaWiki does not support installations where register_globals is enabled. '
33 . 'Please see <a href="https://www.mediawiki.org/wiki/register_globals">mediawiki.org</a> '
34 . 'for help on how to disable it.' );
37 # bug 15461: Make IE8 turn off content sniffing. Everybody else should ignore this
38 # We're adding it here so that it's *always* set, even for alternate entry
39 # points and when $wgOut gets disabled or overridden.
40 header( 'X-Content-Type-Options: nosniff' );
42 $wgRequestTime = microtime( true );
43 unset( $IP );
45 # Valid web server entry point, enable includes.
46 # Please don't move this line to includes/Defines.php. This line essentially
47 # defines a valid entry point. If you put it in includes/Defines.php, then
48 # any script that includes it becomes an entry point, thereby defeating
49 # its purpose.
50 define( 'MEDIAWIKI', true );
52 # Full path to working directory.
53 # Makes it possible to for example to have effective exclude path in apc.
54 # __DIR__ breaks symlinked includes, but realpath() returns false
55 # if we don't have permissions on parent directories.
56 $IP = getenv( 'MW_INSTALL_PATH' );
57 if ( $IP === false ) {
58 $IP = realpath( '.' ) ?: dirname( __DIR__ );
61 # Grab profiling functions
62 require_once "$IP/includes/profiler/ProfilerFunctions.php";
63 $wgRUstart = wfGetRusage() ?: array();
65 # Start the autoloader, so that extensions can derive classes from core files
66 require_once "$IP/includes/AutoLoader.php";
68 # Load up some global defines.
69 require_once "$IP/includes/Defines.php";
71 # Start the profiler
72 $wgProfiler = array();
73 if ( file_exists( "$IP/StartProfiler.php" ) ) {
74 require "$IP/StartProfiler.php";
77 wfProfileIn( 'WebStart.php-conf' );
79 # Load default settings
80 require_once "$IP/includes/DefaultSettings.php";
82 # Load composer's autoloader if present
83 if ( is_readable( "$IP/vendor/autoload.php" ) ) {
84 require_once "$IP/vendor/autoload.php";
87 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
88 # Use a callback function to configure MediaWiki
89 call_user_func( MW_CONFIG_CALLBACK );
90 } else {
91 if ( !defined( 'MW_CONFIG_FILE' ) ) {
92 define( 'MW_CONFIG_FILE', "$IP/LocalSettings.php" );
95 # LocalSettings.php is the per site customization file. If it does not exist
96 # the wiki installer needs to be launched or the generated file uploaded to
97 # the root wiki directory. Give a hint, if it is not readable by the server.
98 if ( !is_readable( MW_CONFIG_FILE ) ) {
99 require_once "$IP/includes/templates/NoLocalSettings.php";
100 die();
103 # Include site settings. $IP may be changed (hopefully before the AutoLoader is invoked)
104 require_once MW_CONFIG_FILE;
107 wfProfileOut( 'WebStart.php-conf' );
109 wfProfileIn( 'WebStart.php-ob_start' );
110 # Initialise output buffering
111 # Check that there is no previous output or previously set up buffers, because
112 # that would cause us to potentially mix gzip and non-gzip output, creating a
113 # big mess.
114 if ( ob_get_level() == 0 ) {
115 require_once "$IP/includes/OutputHandler.php";
116 ob_start( 'wfOutputHandler' );
118 wfProfileOut( 'WebStart.php-ob_start' );
120 if ( !defined( 'MW_NO_SETUP' ) ) {
121 require_once "$IP/includes/Setup.php";