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(
140 * Known object cache types and the functions used to test for their existence
143 var $objectCaches = array(
144 'xcache' => 'xcache_get',
145 'apc' => 'apc_fetch',
146 'eaccel' => 'eaccelerator_get',
147 'wincache' => 'wincache_ucache_get'
151 * User rights profiles
153 var $rightsProfiles = array(
156 '*' => array( 'edit' => false )
160 'createaccount' => false,
166 'createaccount' => false,
176 var $licenses = array(
183 'url' => 'http://creativecommons.org/licenses/by-sa/3.0/',
184 'icon' => '{$wgStylePath}/common/images/cc-by-sa.png',
186 'cc-by-nc-sa' => array(
187 'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/',
188 'icon' => '{$wgStylePath}/common/images/cc-by-nc-sa.png',
191 'url' => 'http://creativecommons.org/licenses/publicdomain/',
192 'icon' => '{$wgStylePath}/common/images/public-domain.png',
195 'url' => 'http://www.gnu.org/licenses/old-licenses/fdl-1.2.html',
196 'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
198 'gfdl-current' => array(
199 'url' => 'http://www.gnu.org/copyleft/fdl.html',
200 'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
202 'cc-choose' => array(
203 // details will be filled in by the selector
210 * Cached Title and ParserOptions used by parse()
213 var $parserTitle, $parserOptions;
216 * Constructor, always call this from child classes
218 function __construct() {
219 // Disable the i18n cache and LoadBalancer
220 Language
::getLocalisationCache()->disableBackend();
221 LBFactory
::disableBackend();
223 // Load the installer's i18n file
224 global $wgExtensionMessagesFiles;
225 $wgExtensionMessagesFiles['MediawikiInstaller'] =
226 './includes/installer/Installer.i18n.php';
229 $wgUser = User
::newFromId( 0 );
230 // Having a user with id = 0 safeguards us from DB access via User::loadOptions()
232 // Set our custom <doclink> hook
234 $wgHooks['ParserFirstCallInit'][] = array( $this, 'registerDocLink' );
236 $this->settings
= $this->internalDefaults
;
237 foreach ( $this->defaultVarNames
as $var ) {
238 $this->settings
[$var] = $GLOBALS[$var];
240 foreach ( $this->dbTypes
as $type ) {
241 $installer = $this->getDBInstaller( $type );
242 if ( !$installer->isCompiled() ) {
245 $defaults = $installer->getGlobalDefaults();
246 foreach ( $installer->getGlobalNames() as $var ) {
247 if ( isset( $defaults[$var] ) ) {
248 $this->settings
[$var] = $defaults[$var];
250 $this->settings
[$var] = $GLOBALS[$var];
255 $this->parserTitle
= Title
::newFromText( 'Installer' );
256 $this->parserOptions
= new ParserOptions
;
257 $this->parserOptions
->setEditSection( false );
261 * UI interface for displaying a short message
262 * The parameters are like parameters to wfMsg().
263 * The messages will be in wikitext format, which will be converted to an
264 * output format such as HTML or text before being sent to the user.
266 abstract function showMessage( $msg /*, ... */ );
268 abstract function showStatusMessage( $status );
271 * Get a list of known DB types
273 function getDBTypes() {
274 return $this->dbTypes
;
278 * Get an instance of InstallerDBType for the specified DB type
279 * @param $type Mixed: DB installer for which is needed, false to use default
281 function getDBInstaller( $type = false ) {
283 $type = $this->getVar( 'wgDBtype' );
285 if ( !isset( $this->dbInstallers
[$type] ) ) {
286 $class = ucfirst( $type ). 'Installer';
287 $this->dbInstallers
[$type] = new $class( $this );
289 return $this->dbInstallers
[$type];
293 * Do initial checks of the PHP environment. Set variables according to
294 * the observed environment.
296 * It's possible that this may be called under the CLI SAPI, not the SAPI
297 * that the wiki will primarily run under. In that case, the subclass should
298 * initialise variables such as wgScriptPath, before calling this function.
300 * Under the web subclass, it can already be assumed that PHP 5+ is in use
301 * and that sessions are working.
303 function doEnvironmentChecks() {
304 $this->showMessage( 'config-env-php', phpversion() );
307 foreach ( $this->envChecks
as $check ) {
308 $status = $this->$check();
309 if ( $status === false ) {
313 $this->setVar( '_Environment', $good );
315 $this->showMessage( 'config-env-good' );
317 $this->showMessage( 'config-env-bad' );
323 * Get an MW configuration variable, or internal installer configuration variable.
324 * The defaults come from $GLOBALS (ultimately DefaultSettings.php).
325 * Installer variables are typically prefixed by an underscore.
327 function getVar( $name, $default = null ) {
328 if ( !isset( $this->settings
[$name] ) ) {
331 return $this->settings
[$name];
336 * Set a MW configuration variable, or internal installer configuration variable.
338 function setVar( $name, $value ) {
339 $this->settings
[$name] = $value;
343 * Exports all wg* variables stored by the installer into global scope
345 function exportVars() {
346 foreach ( $this->settings
as $name => $value ) {
347 if ( substr( $name, 0, 2 ) == 'wg' ) {
348 $GLOBALS[$name] = $value;
354 * Get a fake password for sending back to the user in HTML.
355 * This is a security mechanism to avoid compromise of the password in the
356 * event of session ID compromise.
358 function getFakePassword( $realPassword ) {
359 return str_repeat( '*', strlen( $realPassword ) );
363 * Set a variable which stores a password, except if the new value is a
364 * fake password in which case leave it as it is.
366 function setPassword( $name, $value ) {
367 if ( !preg_match( '/^\*+$/', $value ) ) {
368 $this->setVar( $name, $value );
372 /** Check if we're installing the latest version */
373 function envLatestVersion() {
375 $latestInfoUrl = 'http://www.mediawiki.org/w/api.php?action=mwreleases&format=json';
376 $latestInfo = Http
::get( $latestInfoUrl );
378 $this->showMessage( 'config-env-latest-can-not-check', $latestInfoUrl );
381 $latestInfo = FormatJson
::decode($latestInfo);
382 if ($latestInfo === false ||
!isset( $latestInfo->mwreleases
) ) {
383 # For when the request is successful but there's e.g. some silly man in
384 # the middle firewall blocking us, e.g. one of those annoying airport ones
385 $this->showMessage( 'config-env-latest-data-invalid', $latestInfoUrl );
388 foreach( $latestInfo->mwreleases
as $rel ) {
389 if( isset( $rel->current
) )
390 $currentVersion = $rel->version
;
392 if( version_compare( $wgVersion, $currentVersion, '<' ) ) {
393 $this->showMessage( 'config-env-latest-old' );
394 $this->showHelpBox( 'config-env-latest-help', $wgVersion, $currentVersion );
395 } elseif( version_compare( $wgVersion, $currentVersion, '>' ) ) {
396 $this->showMessage( 'config-env-latest-new' );
398 $this->showMessage( 'config-env-latest-ok' );
401 /** Environment check for DB types */
402 function envCheckDB() {
403 $compiledDBs = array();
404 $goodNames = array();
406 foreach ( $this->dbTypes
as $name ) {
407 $db = $this->getDBInstaller( $name );
408 $readableName = wfMsg( 'config-type-' . $name );
409 if ( $db->isCompiled() ) {
410 $compiledDBs[] = $name;
411 $goodNames[] = $readableName;
413 $allNames[] = $readableName;
415 $this->setVar( '_CompiledDBs', $compiledDBs );
418 if ( !$compiledDBs ) {
419 $this->showMessage( 'config-no-db' );
420 $this->showHelpBox( 'config-no-db-help', $wgLang->commaList( $allNames ) );
423 $this->showMessage( 'config-have-db', $wgLang->commaList( $goodNames ) );
426 /** Environment check for register_globals */
427 function envCheckRegisterGlobals() {
428 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
429 $this->showMessage( 'config-register-globals' );
433 /** Environment check for magic_quotes_runtime */
434 function envCheckMagicQuotes() {
435 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
436 $this->showMessage( 'config-magic-quotes-runtime' );
441 /** Environment check for magic_quotes_sybase */
442 function envCheckMagicSybase() {
443 if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
444 $this->showMessage( 'config-magic-quotes-sybase' );
449 /* Environment check for mbstring.func_overload */
450 function envCheckMbstring() {
451 if ( wfIniGetBool( 'mbstring.func_overload' ) ) {
452 $this->showMessage( 'config-mbstring' );
457 /** Environment check for zend.ze1_compatibility_mode */
458 function envCheckZE1() {
459 if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) {
460 $this->showMessage( 'config-ze1' );
465 /** Environment check for safe_mode */
466 function envCheckSafeMode() {
467 if ( wfIniGetBool( 'safe_mode' ) ) {
468 $this->setVar( '_SafeMode', true );
469 $this->showMessage( 'config-safe-mode' );
473 /** Environment check for the XML module */
474 function envCheckXML() {
475 if ( !function_exists( "utf8_encode" ) ) {
476 $this->showMessage( 'config-xml-bad' );
479 $this->showMessage( 'config-xml-good' );
482 /** Environment check for the PCRE module */
483 function envCheckPCRE() {
484 if ( !function_exists( 'preg_match' ) ) {
485 $this->showMessage( 'config-pcre' );
490 /** Environment check for available memory */
491 function envCheckMemory() {
492 $limit = ini_get( 'memory_limit' );
493 if ( !$limit ||
$limit == -1 ) {
494 $this->showMessage( 'config-memory-none' );
497 $n = intval( $limit );
498 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $limit ), $m ) ) {
499 $n = intval( $m[1] * (1024*1024) );
501 if( $n < $this->minMemorySize
*1024*1024 ) {
502 $newLimit = "{$this->minMemorySize}M";
503 if( false === ini_set( "memory_limit", $newLimit ) ) {
504 $this->showMessage( 'config-memory-bad', $limit );
506 $this->showMessage( 'config-memory-raised', $limit, $newLimit );
507 $this->setVar( '_RaiseMemory', true );
510 $this->showMessage( 'config-memory-ok', $limit );
514 /** Environment check for compiled object cache types */
515 function envCheckCache() {
517 foreach ( $this->objectCaches
as $name => $function ) {
518 if ( function_exists( $function ) ) {
519 $caches[$name] = true;
520 $this->showMessage( 'config-' . $name );
524 $this->showMessage( 'config-no-cache' );
526 $this->setVar( '_Caches', $caches );
529 /** Search for GNU diff3 */
530 function envCheckDiff3() {
531 $paths = array_merge(
538 explode( PATH_SEPARATOR
, getenv( "PATH" ) ) );
539 $names = array( "gdiff3", "diff3", "diff3.exe" );
541 $versionInfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
543 foreach ( $paths as $path ) {
544 $exe = $this->locateExecutable( $path, $names, $versionInfo );
545 if ($exe !== false) {
546 $this->setVar( 'wgDiff3', $exe );
552 $this->showMessage( 'config-diff3-good', $exe );
554 $this->setVar( 'wgDiff3', false );
555 $this->showMessage( 'config-diff3-bad' );
560 * Search a path for any of the given executable names. Returns the
561 * executable name if found. Also checks the version string returned
564 * @param $path String: path to search
565 * @param $names Array of executable names
566 * @param $versionInfo Boolean false or array with two members:
567 * 0 => Command to run for version check, with $1 for the path
568 * 1 => String to compare the output with
570 * If $versionInfo is not false, only executables with a version
571 * matching $versionInfo[1] will be returned.
573 function locateExecutable( $path, $names, $versionInfo = false ) {
574 if (!is_array($names))
575 $names = array($names);
577 foreach ($names as $name) {
578 $command = "$path/$name";
579 if ( @file_exists
( $command ) ) {
583 $file = str_replace( '$1', $command, $versionInfo[0] );
584 if ( strstr( wfShellExec( $file ), $versionInfo[1]) !== false )
591 /** Environment check for ImageMagick and GD */
592 function envCheckGraphics() {
593 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
594 foreach( $imcheck as $dir ) {
595 $im = "$dir/convert";
596 if( @file_exists
( $im ) ) {
597 $this->showMessage( 'config-imagemagick', $im );
598 $this->setVar( 'wgImageMagickConvertCommand', $im );
602 if ( function_exists( 'imagejpeg' ) ) {
603 $this->showMessage( 'config-gd' );
606 $this->showMessage( 'no-scaling' );
609 /** Environment check for setting $IP and $wgScriptPath */
610 function envCheckPath() {
611 $IP = dirname( dirname( dirname( __FILE__
) ) );
612 $this->setVar( 'IP', $IP );
613 $this->showMessage( 'config-dir', $IP );
615 // PHP_SELF isn't available sometimes, such as when PHP is CGI but
616 // cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
617 // to get the path to the current script... hopefully it's reliable. SIGH
618 if ( !empty( $_SERVER['PHP_SELF'] ) ) {
619 $path = $_SERVER['PHP_SELF'];
620 } elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
621 $path = $_SERVER['SCRIPT_NAME'];
622 } elseif ( $this->getVar( 'wgScriptPath' ) ) {
623 // Some kind soul has set it for us already (e.g. debconf)
626 $this->showMessage( 'config-no-uri' );
629 $uri = preg_replace( '{^(.*)/config.*$}', '$1', $path );
630 $this->setVar( 'wgScriptPath', $uri );
631 $this->showMessage( 'config-uri', $uri );
634 /** Environment check for writable config/ directory */
635 function envCheckWriteableDir() {
636 $ipDir = $this->getVar( 'IP' );
637 $configDir = $ipDir . '/config';
638 if( !is_writeable( $configDir ) ) {
639 $webserverGroup = self
::maybeGetWebserverPrimaryGroup();
640 if ( $webserverGroup !== null ) {
641 $this->showMessage( 'config-dir-not-writable-group', $ipDir, $webserverGroup );
643 $this->showMessage( 'config-dir-not-writable-nogroup', $ipDir, $webserverGroup );
649 /** Environment check for setting the preferred PHP file extension */
650 function envCheckExtension() {
651 // FIXME: detect this properly
652 if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
657 $this->setVar( 'wgScriptExtension', ".$ext" );
658 $this->showMessage( 'config-file-extension', $ext );
661 function envCheckShellLocale() {
662 # Give up now if we're in safe mode or open_basedir
663 # It's theoretically possible but tricky to work with
664 if ( wfIniGetBool( "safe_mode" ) ||
ini_get( 'open_basedir' ) ||
!function_exists( 'exec' ) ) {
668 $os = php_uname( 's' );
669 $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
670 if ( !in_array( $os, $supported ) ) {
674 # Get a list of available locales
675 $lines = $ret = false;
676 exec( '/usr/bin/locale -a', $lines, $ret );
681 $lines = wfArrayMap( 'trim', $lines );
682 $candidatesByLocale = array();
683 $candidatesByLang = array();
684 foreach ( $lines as $line ) {
685 if ( $line === '' ) {
688 if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
691 list( $all, $lang, $territory, $charset, $modifier ) = $m;
692 $candidatesByLocale[$m[0]] = $m;
693 $candidatesByLang[$lang][] = $m;
696 # Try the current value of LANG
697 if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
698 $this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
699 $this->showMessage( 'config-shell-locale', getenv( 'LANG' ) );
703 # Try the most common ones
704 $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
705 foreach ( $commonLocales as $commonLocale ) {
706 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
707 $this->setVar( 'wgShellLocale', $commonLocale );
708 $this->showMessage( 'config-shell-locale', $commonLocale );
713 # Is there an available locale in the Wiki's language?
714 $wikiLang = $this->getVar( 'wgLanguageCode' );
715 if ( isset( $candidatesByLang[$wikiLang] ) ) {
716 $m = reset( $candidatesByLang[$wikiLang] );
717 $this->setVar( 'wgShellLocale', $m[0] );
718 $this->showMessage( 'config-shell-locale', $m[0] );
722 # Are there any at all?
723 if ( count( $candidatesByLocale ) ) {
724 $m = reset( $candidatesByLocale );
725 $this->setVar( 'wgShellLocale', $m[0] );
726 $this->showMessage( 'config-shell-locale', $m[0] );
734 function envCheckUploadsDirectory() {
735 global $IP, $wgServer;
736 $dir = $IP . '/images/';
737 $url = $wgServer . $this->getVar( 'wgScriptPath' ) . '/images/';
738 $safe = !$this->dirIsExecutable( $dir, $url );
740 $this->showMessage( 'config-uploads-safe' );
742 $this->showMessage( 'config-uploads-not-safe', $dir );
747 * Checks if scripts located in the given directory can be executed via the given URL
749 function dirIsExecutable( $dir, $url ) {
750 $scriptTypes = array(
752 "<?php echo 'ex' . 'ec';",
753 "#!/var/env php5\n<?php echo 'ex' . 'ec';",
756 // it would be good to check other popular languages here, but it'll be slow
758 wfSuppressWarnings();
759 foreach ( $scriptTypes as $ext => $contents ) {
760 foreach ( $contents as $source ) {
761 $file = 'exectest.' . $ext;
762 if ( !file_put_contents( $dir . $file, $source ) ) {
765 $text = Http
::get( $url . $file );
766 unlink( $dir . $file );
767 if ( $text == 'exec' ) {
778 * Convert wikitext $text to HTML.
780 * This is potentially error prone since many parser features require a complete
781 * installed MW database. The solution is to just not use those features when you
782 * write your messages. This appears to work well enough. Basic formatting and
783 * external links work just fine.
785 * But in case a translator decides to throw in a #ifexist or internal link or
786 * whatever, this function is guarded to catch attempted DB access and to present
787 * some fallback text.
789 * @param $text String
790 * @param $lineStart Boolean
793 function parse( $text, $lineStart = false ) {
796 $out = $wgParser->parse( $text, $this->parserTitle
, $this->parserOptions
, $lineStart );
797 $html = $out->getText();
798 } catch ( DBAccessError
$e ) {
799 $html = '<!--DB access attempted during parse--> ' . htmlspecialchars( $text );
800 if ( !empty( $this->debug
) ) {
801 $html .= "<!--\n" . $e->getTraceAsString() . "\n-->";
808 * Register tag hook below
810 function registerDocLink( &$parser ) {
811 $parser->setHook( 'doclink', array( $this, 'docLink' ) );
816 * Extension tag hook for a documentation link
818 function docLink( $linkText, $attribs, $parser ) {
819 $url = $this->getDocUrl( $attribs['href'] );
820 return '<a href="' . htmlspecialchars( $url ) . '">' .
821 htmlspecialchars( $linkText ) .
826 * Overridden by WebInstaller to provide lastPage parameters
828 protected function getDocUrl( $page ) {
829 return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $attribs['href'] );
832 public function findExtensions() {
833 if( $this->getVar( 'IP' ) === null ) {
837 $dir = $this->getVar( 'IP' ) . '/extensions';
838 $dh = opendir( $dir );
839 while ( ( $file = readdir( $dh ) ) !== false ) {
840 if( file_exists( "$dir/$file/$file.php" ) ) {
844 $this->setVar( '_Extensions', $exts );
848 public function getInstallSteps() {
849 if( $this->getVar( '_UpgradeDone' ) ) {
850 $this->installSteps
= array( 'localsettings' );
852 if( count( $this->getVar( '_Extensions' ) ) ) {
853 array_unshift( $this->installSteps
, 'extensions' );
855 return $this->installSteps
;
858 public function installExtensions() {
859 global $wgHooks, $wgAutoloadClasses;
860 $exts = $this->getVar( '_Extensions' );
861 $path = $this->getVar( 'IP' ) . '/extensions';
862 foreach( $exts as $e ) {
863 require( "$path/$e/$e.php" );
865 return Status
::newGood();
868 public function installDatabase() {
869 $installer = $this->getDBInstaller( $this->getVar( 'wgDBtype' ) );
870 $status = $installer->setupDatabase();
874 public function installUser() {
875 $installer = $this->getDBInstaller( $this->getVar( 'wgDBtype' ) );
876 $status = $installer->setupUser();
880 public function installTables() {
881 $installer = $this->getDBInstaller();
882 $status = $installer->createTables();
883 if( $status->isOK() ) {
884 LBFactory
::enableBackend();
889 public function installInterwiki() {
890 $installer = $this->getDBInstaller();
891 return $installer->populateInterwikiTable();
894 public function installSecretKey() {
895 if ( wfIsWindows() ) {
898 wfSuppressWarnings();
899 $file = fopen( "/dev/urandom", "r" );
903 $status = Status
::newGood();
906 $secretKey = bin2hex( fread( $file, 32 ) );
910 for ( $i=0; $i<8; $i++
) {
911 $secretKey .= dechex(mt_rand(0, 0x7fffffff));
913 $status->warning( 'config-insecure-secretkey' );
915 $this->setVar( 'wgSecretKey', $secretKey );
920 public function installSysop() {
921 $name = $this->getVar( '_AdminName' );
922 $user = User
::newFromName( $name );
924 // we should've validated this earlier anyway!
925 return Status
::newFatal( 'config-admin-error-user', $name );
927 if ( $user->idForName() == 0 ) {
928 $user->addToDatabase();
930 $user->setPassword( $this->getVar( '_AdminPassword' ) );
931 } catch( PasswordError
$pwe ) {
932 return Status
::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
934 $user->addGroup( 'sysop' );
935 $user->addGroup( 'bureaucrat' );
936 $user->saveSettings();
938 return Status
::newGood();
941 public function installLocalsettings() {
942 $localSettings = new LocalSettingsGenerator( $this );
943 return $localSettings->writeLocalSettings();
947 * On POSIX systems return the primary group of the webserver we're running under.
948 * On other systems just returns null.
950 * This is used to advice the user that he should chgrp his config/data/images directory as the
951 * webserver user before he can install.
953 * Public because SqliteInstaller needs it, and doesn't subclass Installer.
957 public static function maybeGetWebserverPrimaryGroup() {
958 if ( ! function_exists('posix_getegid') ||
! function_exists('posix_getpwuid') ) {
959 # I don't know this, this isn't UNIX
963 # posix_getegid() *not* getmygid() because we want the group of the webserver,
964 # not whoever owns the current script
965 $gid = posix_getegid();
966 $getpwuid = posix_getpwuid( $gid );
967 $group = $getpwuid["name"];
973 * Override the necessary bits of the config to run an installation
975 public static function overrideConfig() {
976 define( 'MW_NO_SESSION', 1 );
978 // Don't access the database
979 $GLOBALS['wgUseDatabaseMessages'] = false;
981 $GLOBALS['wgShowExceptionDetails'] = true;
983 $GLOBALS['wgExternalLinkTarget'] = '_blank';
985 // Extended debugging. Maybe disable before release?
986 $GLOBALS['wgShowSQLErrors'] = true;
987 $GLOBALS['wgShowDBErrorBacktrace'] = true;