MediaWiki REL1_40
BootstrapHelperFunctions.php
Go to the documentation of this file.
1<?php
30function wfDetectLocalSettingsFile( ?string $installationPath = null ): string {
31 if ( defined( 'MW_CONFIG_FILE' ) ) {
32 return MW_CONFIG_FILE;
33 }
34
35 if ( $installationPath === null ) {
36 $installationPath = wfDetectInstallPath();
37 }
38
39 // We could look for LocalSettings.yaml and LocalSettings.json,
40 // and use them if they exist. But having them in a web accessible
41 // place is dangerous, so better not to encourage that.
42 // In order to use LocalSettings.yaml and LocalSettings.json, they
43 // will have to be referenced explicitly by MW_CONFIG_FILE.
44 $configFile = getenv( 'MW_CONFIG_FILE' ) ?: "LocalSettings.php";
45 // Can't use str_contains because for maintenance scripts (update.php, install.php),
46 // this is called *before* Setup.php and vendor (polyfill-php80) are included.
47 if ( strpos( $configFile, '/' ) === false ) {
48 $configFile = "$installationPath/$configFile";
49 }
50
51 define( 'MW_CONFIG_FILE', $configFile );
52 return $configFile;
53}
54
68function wfDetectInstallPath(): string {
69 if ( !defined( 'MW_INSTALL_PATH' ) ) {
70 $IP = getenv( 'MW_INSTALL_PATH' );
71 if ( $IP === false ) {
72 $IP = dirname( __DIR__ );
73 }
74 define( 'MW_INSTALL_PATH', $IP );
75 }
76
77 return MW_INSTALL_PATH;
78}
79
85function wfIsWindows() {
86 return PHP_OS_FAMILY === 'Windows';
87}
88
95function wfIsCLI() {
96 return PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg';
97}
wfDetectLocalSettingsFile(?string $installationPath=null)
Decide and remember where to load LocalSettings from.
wfIsWindows()
Check if the operating system is Windows.
wfDetectInstallPath()
Decide and remember where mediawiki is installed.
wfIsCLI()
Check if we are running from the commandline.
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Definition Setup.php:93
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:88