5 * Handles everything that is independent of user interface
7 abstract class Installer
{
8 var $settings, $output;
11 * MediaWiki configuration globals that will eventually be passed through
12 * to LocalSettings.php. The names only are given here, the defaults
13 * typically come from DefaultSettings.php.
16 var $defaultVarNames = array(
28 'wgEmailAuthentication',
31 'wgImageMagickConvertCommand',
36 // 'wgDeletedDirectory',
44 * Variables that are stored alongside globals, and are used for any
45 * configuration of the installation process aside from the MediaWiki
46 * configuration. Map of names to defaults.
49 var $internalDefaults = array(
51 '_Environment' => false,
52 '_CompiledDBs' => array(),
54 '_RaiseMemory' => false,
55 '_UpgradeDone' => false,
57 '_InstallUser' => 'root',
58 '_InstallPassword' => '',
59 '_SameAccount' => true,
60 '_CreateDBAccount' => false,
61 '_NamespaceType' => 'site-name',
62 '_AdminName' => null, // will be set later, when the user selects language
63 '_AdminPassword' => '',
64 '_AdminPassword2' => '',
66 '_Subscribe' => false,
67 '_SkipOptional' => 'continue',
68 '_RightsProfile' => 'wiki',
69 '_LicenseCode' => 'none',
71 '_Extensions' => array(),
72 '_MemCachedServers' => '',
76 * Known database types. These correspond to the class names <type>Installer,
77 * and are also MediaWiki database types valid for $wgDBtype.
79 * To add a new type, create a <type>Installer class and a Database<type>
80 * class, and add a config-type-<type> message to MessagesEn.php.
91 * Minimum memory size in MB
93 private $minMemorySize = 50;
96 * Cached DB installer instances, access using getDBInstaller()
99 var $dbInstallers = array();
102 * A list of environment check methods called by doEnvironmentChecks().
103 * These may output warnings using showMessage(), and/or abort the
104 * installation process by returning false.
107 var $envChecks = array(
110 'envCheckRegisterGlobals',
111 'envCheckMagicQuotes',
112 'envCheckMagicSybase',
123 'envCheckWriteableDir',
125 'envCheckShellLocale',
126 'envCheckUploadsDirectory',
129 var $installSteps = array(
139 * Known object cache types and the functions used to test for their existence
142 var $objectCaches = array(
143 'xcache' => 'xcache_get',
144 'apc' => 'apc_fetch',
145 'eaccel' => 'eaccelerator_get',
146 'wincache' => 'wincache_ucache_get'
150 * User rights profiles
152 var $rightsProfiles = array(
155 '*' => array( 'edit' => false )
159 'createaccount' => false,
165 'createaccount' => false,
175 var $licenses = array(
182 'url' => 'http://creativecommons.org/licenses/by-sa/3.0/',
183 'icon' => '{$wgStylePath}/common/images/cc-by-sa.png',
185 'cc-by-nc-sa' => array(
186 'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/',
187 'icon' => '{$wgStylePath}/common/images/cc-by-nc-sa.png',
190 'url' => 'http://creativecommons.org/licenses/publicdomain/',
191 'icon' => '{$wgStylePath}/common/images/public-domain.png',
194 'url' => 'http://www.gnu.org/licenses/old-licenses/fdl-1.2.html',
195 'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
197 'gfdl-current' => array(
198 'url' => 'http://www.gnu.org/copyleft/fdl.html',
199 'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
201 'cc-choose' => array(
202 // details will be filled in by the selector
209 * Cached Title and ParserOptions used by parse()
212 var $parserTitle, $parserOptions;
215 * Constructor, always call this from child classes
217 function __construct() {
218 // Disable the i18n cache and LoadBalancer
219 Language
::getLocalisationCache()->disableBackend();
220 LBFactory
::disableBackend();
222 // Load the installer's i18n file
223 global $wgExtensionMessagesFiles;
224 $wgExtensionMessagesFiles['MediawikiInstaller'] =
225 './includes/installer/Installer.i18n.php';
227 // Set our custom <doclink> hook
229 $wgHooks['ParserFirstCallInit'][] = array( $this, 'registerDocLink' );
231 $this->settings
= $this->internalDefaults
;
232 foreach ( $this->defaultVarNames
as $var ) {
233 $this->settings
[$var] = $GLOBALS[$var];
235 foreach ( $this->dbTypes
as $type ) {
236 $installer = $this->getDBInstaller( $type );
237 if ( !$installer->isCompiled() ) {
240 $defaults = $installer->getGlobalDefaults();
241 foreach ( $installer->getGlobalNames() as $var ) {
242 if ( isset( $defaults[$var] ) ) {
243 $this->settings
[$var] = $defaults[$var];
245 $this->settings
[$var] = $GLOBALS[$var];
250 $this->parserTitle
= Title
::newFromText( 'Installer' );
251 $this->parserOptions
= new ParserOptions
;
252 $this->parserOptions
->setEditSection( false );
256 * UI interface for displaying a short message
257 * The parameters are like parameters to wfMsg().
258 * The messages will be in wikitext format, which will be converted to an
259 * output format such as HTML or text before being sent to the user.
261 abstract function showMessage( $msg /*, ... */ );
263 abstract function showStatusMessage( $status );
266 * Get a list of known DB types
268 function getDBTypes() {
269 return $this->dbTypes
;
273 * Get an instance of InstallerDBType for the specified DB type
274 * @param $type Mixed: DB installer for which is needed, false to use default
276 function getDBInstaller( $type = false ) {
278 $type = $this->getVar( 'wgDBtype' );
280 if ( !isset( $this->dbInstallers
[$type] ) ) {
281 $class = ucfirst( $type ). 'Installer';
282 $this->dbInstallers
[$type] = new $class( $this );
284 return $this->dbInstallers
[$type];
288 * Do initial checks of the PHP environment. Set variables according to
289 * the observed environment.
291 * It's possible that this may be called under the CLI SAPI, not the SAPI
292 * that the wiki will primarily run under. In that case, the subclass should
293 * initialise variables such as wgScriptPath, before calling this function.
295 * Under the web subclass, it can already be assumed that PHP 5+ is in use
296 * and that sessions are working.
298 function doEnvironmentChecks() {
299 $this->showMessage( 'config-env-php', phpversion() );
302 foreach ( $this->envChecks
as $check ) {
303 $status = $this->$check();
304 if ( $status === false ) {
308 $this->setVar( '_Environment', $good );
310 $this->showMessage( 'config-env-good' );
312 $this->showMessage( 'config-env-bad' );
318 * Get an MW configuration variable, or internal installer configuration variable.
319 * The defaults come from $GLOBALS (ultimately DefaultSettings.php).
320 * Installer variables are typically prefixed by an underscore.
322 function getVar( $name, $default = null ) {
323 if ( !isset( $this->settings
[$name] ) ) {
326 return $this->settings
[$name];
331 * Set a MW configuration variable, or internal installer configuration variable.
333 function setVar( $name, $value ) {
334 $this->settings
[$name] = $value;
338 * Exports all wg* variables stored by the installer into global scope
340 function exportVars() {
341 foreach ( $this->settings
as $name => $value ) {
342 if ( substr( $name, 0, 2 ) == 'wg' ) {
343 $GLOBALS[$name] = $value;
349 * Get a fake password for sending back to the user in HTML.
350 * This is a security mechanism to avoid compromise of the password in the
351 * event of session ID compromise.
353 function getFakePassword( $realPassword ) {
354 return str_repeat( '*', strlen( $realPassword ) );
358 * Set a variable which stores a password, except if the new value is a
359 * fake password in which case leave it as it is.
361 function setPassword( $name, $value ) {
362 if ( !preg_match( '/^\*+$/', $value ) ) {
363 $this->setVar( $name, $value );
367 /** Check if we're installing the latest version */
368 function envLatestVersion() {
370 $latestInfoUrl = 'http://www.mediawiki.org/w/api.php?action=mwreleases&format=json';
371 $latestInfo = Http
::get( $latestInfoUrl );
373 $this->showMessage( 'config-env-latest-can-not-check', $latestInfoUrl );
376 $latestInfo = FormatJson
::decode($latestInfo);
377 if ($latestInfo === false ||
!isset( $latestInfo->mwreleases
) ) {
378 # For when the request is successful but there's e.g. some silly man in
379 # the middle firewall blocking us, e.g. one of those annoying airport ones
380 $this->showMessage( 'config-env-latest-data-invalid', $latestInfoUrl );
383 foreach( $latestInfo->mwreleases
as $rel ) {
384 if( isset( $rel->current
) )
385 $currentVersion = $rel->version
;
387 if( version_compare( $wgVersion, $currentVersion, '<' ) ) {
388 $this->showMessage( 'config-env-latest-old' );
389 $this->showHelpBox( 'config-env-latest-help', $wgVersion, $currentVersion );
390 } elseif( version_compare( $wgVersion, $currentVersion, '>' ) ) {
391 $this->showMessage( 'config-env-latest-new' );
393 $this->showMessage( 'config-env-latest-ok' );
396 /** Environment check for DB types */
397 function envCheckDB() {
398 $compiledDBs = array();
399 $goodNames = array();
401 foreach ( $this->dbTypes
as $name ) {
402 $db = $this->getDBInstaller( $name );
403 $readableName = wfMsg( 'config-type-' . $name );
404 if ( $db->isCompiled() ) {
405 $compiledDBs[] = $name;
406 $goodNames[] = $readableName;
408 $allNames[] = $readableName;
410 $this->setVar( '_CompiledDBs', $compiledDBs );
413 if ( !$compiledDBs ) {
414 $this->showMessage( 'config-no-db' );
415 $this->showHelpBox( 'config-no-db-help', $wgLang->commaList( $allNames ) );
418 $this->showMessage( 'config-have-db', $wgLang->commaList( $goodNames ) );
421 /** Environment check for register_globals */
422 function envCheckRegisterGlobals() {
423 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
424 $this->showMessage( 'config-register-globals' );
428 /** Environment check for magic_quotes_runtime */
429 function envCheckMagicQuotes() {
430 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
431 $this->showMessage( 'config-magic-quotes-runtime' );
436 /** Environment check for magic_quotes_sybase */
437 function envCheckMagicSybase() {
438 if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
439 $this->showMessage( 'config-magic-quotes-sybase' );
444 /* Environment check for mbstring.func_overload */
445 function envCheckMbstring() {
446 if ( wfIniGetBool( 'mbstring.func_overload' ) ) {
447 $this->showMessage( 'config-mbstring' );
452 /** Environment check for zend.ze1_compatibility_mode */
453 function envCheckZE1() {
454 if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) {
455 $this->showMessage( 'config-ze1' );
460 /** Environment check for safe_mode */
461 function envCheckSafeMode() {
462 if ( wfIniGetBool( 'safe_mode' ) ) {
463 $this->setVar( '_SafeMode', true );
464 $this->showMessage( 'config-safe-mode' );
468 /** Environment check for the XML module */
469 function envCheckXML() {
470 if ( !function_exists( "utf8_encode" ) ) {
471 $this->showMessage( 'config-xml-bad' );
474 $this->showMessage( 'config-xml-good' );
477 /** Environment check for the PCRE module */
478 function envCheckPCRE() {
479 if ( !function_exists( 'preg_match' ) ) {
480 $this->showMessage( 'config-pcre' );
485 /** Environment check for available memory */
486 function envCheckMemory() {
487 $limit = ini_get( 'memory_limit' );
488 if ( !$limit ||
$limit == -1 ) {
489 $this->showMessage( 'config-memory-none' );
492 $n = intval( $limit );
493 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $limit ), $m ) ) {
494 $n = intval( $m[1] * (1024*1024) );
496 if( $n < $this->minMemorySize
*1024*1024 ) {
497 $newLimit = "{$this->minMemorySize}M";
498 if( false === ini_set( "memory_limit", $newLimit ) ) {
499 $this->showMessage( 'config-memory-bad', $limit );
501 $this->showMessage( 'config-memory-raised', $limit, $newLimit );
502 $this->setVar( '_RaiseMemory', true );
505 $this->showMessage( 'config-memory-ok', $limit );
509 /** Environment check for compiled object cache types */
510 function envCheckCache() {
512 foreach ( $this->objectCaches
as $name => $function ) {
513 if ( function_exists( $function ) ) {
514 $caches[$name] = true;
515 $this->showMessage( 'config-' . $name );
519 $this->showMessage( 'config-no-cache' );
521 $this->setVar( '_Caches', $caches );
524 /** Search for GNU diff3 */
525 function envCheckDiff3() {
526 $paths = array_merge(
533 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
534 $names = array( "gdiff3", "diff3", "diff3.exe" );
536 $versionInfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
538 foreach ( $paths as $path ) {
539 $exe = $this->locateExecutable( $path, $names, $versionInfo );
540 if ($exe !== false) {
541 $this->setVar( 'wgDiff3', $exe );
547 $this->showMessage( 'config-diff3-good', $exe );
549 $this->setVar( 'wgDiff3', false );
550 $this->showMessage( 'config-diff3-bad' );
555 * Search a path for any of the given executable names. Returns the
556 * executable name if found. Also checks the version string returned
559 * @param $path String: path to search
560 * @param $names Array of executable names
561 * @param $versionInfo Boolean false or array with two members:
562 * 0 => Command to run for version check, with $1 for the path
563 * 1 => String to compare the output with
565 * If $versionInfo is not false, only executables with a version
566 * matching $versionInfo[1] will be returned.
568 function locateExecutable( $path, $names, $versionInfo = false ) {
569 if (!is_array($names))
570 $names = array($names);
572 foreach ($names as $name) {
573 $command = "$path/$name";
574 if ( @file_exists
( $command ) ) {
578 $file = str_replace( '$1', $command, $versionInfo[0] );
579 if ( strstr( wfShellExec( $file ), $versionInfo[1]) !== false )
586 /** Environment check for ImageMagick and GD */
587 function envCheckGraphics() {
588 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
589 foreach( $imcheck as $dir ) {
590 $im = "$dir/convert";
591 if( @file_exists
( $im ) ) {
592 $this->showMessage( 'config-imagemagick', $im );
593 $this->setVar( 'wgImageMagickConvertCommand', $im );
597 if ( function_exists( 'imagejpeg' ) ) {
598 $this->showMessage( 'config-gd' );
601 $this->showMessage( 'no-scaling' );
604 /** Environment check for setting $IP and $wgScriptPath */
605 function envCheckPath() {
606 $IP = dirname( dirname( dirname( __FILE__
) ) );
607 $this->setVar( 'IP', $IP );
608 $this->showMessage( 'config-dir', $IP );
610 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
611 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
612 // to get the path to the current script... hopefully it's reliable. SIGH
613 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
614 $path = $_SERVER['PHP_SELF'];
615 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
616 $path = $_SERVER['SCRIPT_NAME'];
617 } elseif ( $this->getVar( 'wgScriptPath' ) ) {
618 // Some kind soul has set it for us already (e.g. debconf)
621 $this->showMessage( 'config-no-uri' );
624 $uri = preg_replace( '{^(.*)/config.*$}', '$1', $path );
625 $this->setVar( 'wgScriptPath', $uri );
626 $this->showMessage( 'config-uri', $uri );
629 /** Environment check for writable config/ directory */
630 function envCheckWriteableDir() {
631 $ipDir = $this->getVar( 'IP' );
632 $configDir = $ipDir . '/config';
633 if( !is_writeable( $configDir ) ) {
634 $webserverGroup = self
::maybeGetWebserverPrimaryGroup();
635 if ( $webserverGroup !== null ) {
636 $this->showMessage( 'config-dir-not-writable-group', $ipDir, $webserverGroup );
638 $this->showMessage( 'config-dir-not-writable-nogroup', $ipDir, $webserverGroup );
644 /** Environment check for setting the preferred PHP file extension */
645 function envCheckExtension() {
646 // FIXME: detect this properly
647 if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
652 $this->setVar( 'wgScriptExtension', ".$ext" );
653 $this->showMessage( 'config-file-extension', $ext );
656 function envCheckShellLocale() {
657 # Give up now if we're in safe mode or open_basedir
658 # It's theoretically possible but tricky to work with
659 if ( wfIniGetBool( "safe_mode" ) ||
ini_get( 'open_basedir' ) ||
!function_exists( 'exec' ) ) {
663 $os = php_uname( 's' );
664 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
665 if ( !in_array( $os, $supported ) ) {
669 # Get a list of available locales
670 $lines = $ret = false;
671 exec( '/usr/bin/locale -a', $lines, $ret );
676 $lines = wfArrayMap( 'trim', $lines );
677 $candidatesByLocale = array();
678 $candidatesByLang = array();
679 foreach ( $lines as $line ) {
680 if ( $line === '' ) {
683 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
686 list( $all, $lang, $territory, $charset, $modifier ) = $m;
687 $candidatesByLocale[$m[0]] = $m;
688 $candidatesByLang[$lang][] = $m;
691 # Try the current value of LANG
692 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
693 $this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
694 $this->showMessage( 'config-shell-locale', getenv( 'LANG' ) );
698 # Try the most common ones
699 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
700 foreach ( $commonLocales as $commonLocale ) {
701 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
702 $this->setVar( 'wgShellLocale', $commonLocale );
703 $this->showMessage( 'config-shell-locale', $commonLocale );
708 # Is there an available locale in the Wiki's language?
709 $wikiLang = $this->getVar( 'wgLanguageCode' );
710 if ( isset( $candidatesByLang[$wikiLang] ) ) {
711 $m = reset( $candidatesByLang[$wikiLang] );
712 $this->setVar( 'wgShellLocale', $m[0] );
713 $this->showMessage( 'config-shell-locale', $m[0] );
717 # Are there any at all?
718 if ( count( $candidatesByLocale ) ) {
719 $m = reset( $candidatesByLocale );
720 $this->setVar( 'wgShellLocale', $m[0] );
721 $this->showMessage( 'config-shell-locale', $m[0] );
729 function envCheckUploadsDirectory() {
730 global $IP, $wgServer;
731 $dir = $IP . '/images/';
732 $url = $wgServer . $this->getVar( 'wgScriptPath' ) . '/images/';
733 $safe = !$this->dirIsExecutable( $dir, $url );
735 $this->showMessage( 'config-uploads-safe' );
737 $this->showMessage( 'config-uploads-not-safe', $dir );
742 * Checks if scripts located in the given directory can be executed via the given URL
744 function dirIsExecutable( $dir, $url ) {
745 $scriptTypes = array(
747 "<?php echo 'ex' . 'ec';",
748 "#!/var/env php5\n<?php echo 'ex' . 'ec';",
751 // it would be good to check other popular languages here, but it'll be slow
753 wfSuppressWarnings();
754 foreach ( $scriptTypes as $ext => $contents ) {
755 foreach ( $contents as $source ) {
756 $file = 'exectest.' . $ext;
757 if ( !file_put_contents( $dir . $file, $source ) ) {
760 $text = Http
::get( $url . $file );
761 unlink( $dir . $file );
762 if ( $text == 'exec' ) {
773 * Convert wikitext $text to HTML.
775 * This is potentially error prone since many parser features require a complete
776 * installed MW database. The solution is to just not use those features when you
777 * write your messages. This appears to work well enough. Basic formatting and
778 * external links work just fine.
780 * But in case a translator decides to throw in a #ifexist or internal link or
781 * whatever, this function is guarded to catch attempted DB access and to present
782 * some fallback text.
784 * @param $text String
785 * @param $lineStart Boolean
788 function parse( $text, $lineStart = false ) {
791 $out = $wgParser->parse( $text, $this->parserTitle
, $this->parserOptions
, $lineStart );
792 $html = $out->getText();
793 } catch ( DBAccessError
$e ) {
794 $html = '<!--DB access attempted during parse--> ' . htmlspecialchars( $text );
795 if ( !empty( $this->debug
) ) {
796 $html .= "<!--\n" . $e->getTraceAsString() . "\n-->";
803 * Register tag hook below
805 function registerDocLink( &$parser ) {
806 $parser->setHook( 'doclink', array( $this, 'docLink' ) );
811 * Extension tag hook for a documentation link
813 function docLink( $linkText, $attribs, $parser ) {
814 $url = $this->getDocUrl( $attribs['href'] );
815 return '<a href="' . htmlspecialchars( $url ) . '">' .
816 htmlspecialchars( $linkText ) .
821 * Overridden by WebInstaller to provide lastPage parameters
823 protected function getDocUrl( $page ) {
824 return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $attribs['href'] );
827 public function findExtensions() {
828 if( $this->getVar( 'IP' ) === null ) {
832 $dir = $this->getVar( 'IP' ) . '/extensions';
833 $dh = opendir( $dir );
834 while ( ( $file = readdir( $dh ) ) !== false ) {
835 if( file_exists( "$dir/$file/$file.php" ) ) {
839 $this->setVar( '_Extensions', $exts );
843 public function getInstallSteps() {
844 if( $this->getVar( '_UpgradeDone' ) ) {
845 $this->installSteps
= array( 'localsettings' );
847 if( count( $this->getVar( '_Extensions' ) ) ) {
848 array_unshift( $this->installSteps
, 'extensions' );
850 return $this->installSteps
;
853 public function installExtensions() {
854 global $wgHooks, $wgAutoloadClasses;
855 $exts = $this->getVar( '_Extensions' );
856 $path = $this->getVar( 'IP' ) . '/extensions';
857 foreach( $exts as $e ) {
858 require( "$path/$e/$e.php" );
860 return Status
::newGood();
863 public function installDatabase() {
864 $installer = $this->getDBInstaller( $this->getVar( 'wgDBtype' ) );
865 $status = $installer->setupDatabase();
869 public function installTables() {
870 $installer = $this->getDBInstaller();
871 $status = $installer->createTables();
872 if( $status->isOK() ) {
873 LBFactory
::enableBackend();
878 public function installInterwiki() {
879 $installer = $this->getDBInstaller();
880 return $installer->populateInterwikiTable();
883 public function installSecretKey() {
884 if ( wfIsWindows() ) {
887 wfSuppressWarnings();
888 $file = fopen( "/dev/urandom", "r" );
892 $status = Status
::newGood();
895 $secretKey = bin2hex( fread( $file, 32 ) );
899 for ( $i=0; $i<8; $i++
) {
900 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
902 $status->warning( 'config-insecure-secretkey' );
904 $this->setVar( 'wgSecretKey', $secretKey );
909 public function installSysop() {
910 $name = $this->getVar( '_AdminName' );
911 $user = User
::newFromName( $name );
913 // we should've validated this earlier anyway!
914 return Status
::newFatal( 'config-admin-error-user', $name );
916 if ( $user->idForName() == 0 ) {
917 $user->addToDatabase();
919 $user->setPassword( $this->getVar( '_AdminPassword' ) );
920 } catch( PasswordError
$pwe ) {
921 return Status
::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
923 $user->addGroup( 'sysop' );
924 $user->addGroup( 'bureaucrat' );
925 $user->saveSettings();
927 return Status
::newGood();
930 public function installLocalsettings() {
931 $localSettings = new LocalSettingsGenerator( $this );
932 return $localSettings->writeLocalSettings();
936 * On POSIX systems return the primary group of the webserver we're running under.
937 * On other systems just returns null.
939 * This is used to advice the user that he should chgrp his config/data/images directory as the
940 * webserver user before he can install.
942 * Public because SqliteInstaller needs it, and doesn't subclass Installer.
946 public static function maybeGetWebserverPrimaryGroup() {
947 if ( ! function_exists('posix_getegid') ||
! function_exists('posix_getpwuid') ) {
948 # I don't know this, this isn't UNIX
952 # posix_getegid() *not* getmygid() because we want the group of the webserver,
953 # not whoever owns the current script
954 $gid = posix_getegid();
955 $getpwuid = posix_getpwuid( $gid );
956 $group = $getpwuid["name"];
962 * Override the necessary bits of the config to run an installation
964 public static function overrideConfig() {
965 define( 'MW_NO_SESSION', 1 );
967 // Don't access the database
968 $GLOBALS['wgUseDatabaseMessages'] = false;
970 $GLOBALS['wgShowExceptionDetails'] = true;
972 $GLOBALS['wgExternalLinkTarget'] = '_blank';
974 // Extended debugging. Maybe disable before release?
975 $GLOBALS['wgShowSQLErrors'] = true;
976 $GLOBALS['wgShowDBErrorBacktrace'] = true;