MediaWiki  master
index.php
Go to the documentation of this file.
1 <?php
2 // phpcs:disable Generic.Arrays.DisallowLongArraySyntax
25 
26 // Bail on old versions of PHP, or if composer has not been run yet to install
27 // dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+.
28 // phpcs:ignore MediaWiki.Usage.DirUsage.FunctionFound
29 require_once dirname( __FILE__ ) . '/../includes/PHPVersionCheck.php';
30 wfEntryPointCheck( 'html', dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) );
31 
32 define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
33 define( 'MEDIAWIKI_INSTALL', true );
34 
35 // Resolve relative to regular MediaWiki root
36 // instead of mw-config subdirectory.
37 chdir( dirname( __DIR__ ) );
38 require dirname( __DIR__ ) . '/includes/WebStart.php';
39 
41 
42 function wfInstallerMain() {
44  $request = RequestContext::getMain()->getRequest();
45 
46  $installer = InstallerOverrides::getWebInstaller( $request );
47 
48  if ( !$installer->startSession() ) {
49  if ( $installer->request->getVal( 'css' ) ) {
50  // Do not display errors on css pages
51  $installer->outputCss();
52  exit;
53  }
54 
55  $errors = $installer->getPhpErrors();
56  $installer->showError( 'config-session-error', $errors[0] );
57  $installer->finish();
58  exit;
59  }
60 
61  $fingerprint = $installer->getFingerprint();
62  if ( isset( $_SESSION['installData'][$fingerprint] ) ) {
63  $session = $_SESSION['installData'][$fingerprint];
64  } else {
65  $session = array();
66  }
67 
68  if ( $request->getCheck( 'uselang' ) ) {
69  $langCode = $request->getVal( 'uselang' );
70  } elseif ( isset( $session['settings']['_UserLang'] ) ) {
71  $langCode = $session['settings']['_UserLang'];
72  } else {
73  $langCode = 'en';
74  }
75  $wgLang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $langCode );
76  RequestContext::getMain()->setLanguage( $wgLang );
77 
78  $installer->setParserLanguage( $wgLang );
79 
81 
82  $session = $installer->execute( $session );
83 
84  $_SESSION['installData'][$fingerprint] = $session;
85 }
$wgCanonicalNamespaceNames
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
Definition: Setup.php:450
wfInstallerMain
wfInstallerMain()
Definition: index.php:42
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:154
$wgMetaNamespace
$wgMetaNamespace
Name of the project namespace.
Definition: DefaultSettings.php:4249
NS_PROJECT
const NS_PROJECT
Definition: Defines.php:73
$wgLang
$wgLang
Definition: Setup.php:776
InstallerOverrides\getWebInstaller
static getWebInstaller(WebRequest $request)
Instantiates and returns an instance of WebInstaller or its descendant classes.
Definition: InstallerOverrides.php:60
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:453
wfEntryPointCheck
wfEntryPointCheck( $format='text', $scriptPath='/')
Check PHP version and that external dependencies are installed, and display an informative error if e...
Definition: PHPVersionCheck.php:298