X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Finstaller%2FInstaller.php;h=d41f7b8f9f718ed1b14aa737ab981ed8de380599;hb=ebabe9fa35b904a7bc5ad74cb38c8c17b93b35b2;hp=6a7970b031c1ce2b1e81ec4890f2e17d9931f21a;hpb=562acce759552777dd5b9a02bfae95bc3f0164bb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 6a7970b031..d41f7b8f9f 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -46,6 +46,14 @@ abstract class Installer { */ protected $settings; + + /** + * List of detected DBs, access using getCompiledDBs(). + * + * @var array + */ + protected $compiledDBs; + /** * Cached DB installer instances, access using getDBInstaller(). * @@ -175,7 +183,6 @@ abstract class Installer { protected $internalDefaults = array( '_UserLang' => 'en', '_Environment' => false, - '_CompiledDBs' => array(), '_SafeMode' => false, '_RaiseMemory' => false, '_UpgradeDone' => false, @@ -370,7 +377,7 @@ abstract class Installer { } } } - $this->setVar( '_CompiledDBs', $compiledDBs ); + $this->compiledDBs = $compiledDBs; $this->parserTitle = Title::newFromText( 'Installer' ); $this->parserOptions = new ParserOptions; // language will be wrong :( @@ -401,7 +408,7 @@ abstract class Installer { */ public function doEnvironmentChecks() { $phpVersion = phpversion(); - if( version_compare( $phpVersion, self::MINIMUM_PHP_VERSION, '>=' ) ) { + if ( version_compare( $phpVersion, self::MINIMUM_PHP_VERSION, '>=' ) ) { $this->showMessage( 'config-env-php', $phpVersion ); $good = true; } else { @@ -409,7 +416,7 @@ abstract class Installer { $good = false; } - if( $good ) { + if ( $good ) { foreach ( $this->envChecks as $check ) { $status = $this->$check(); if ( $status === false ) { @@ -451,6 +458,15 @@ abstract class Installer { } } + /** + * Get a list of DBs supported by current PHP setup + * + * @return array + */ + public function getCompiledDBs() { + return $this->compiledDBs; + } + /** * Get an instance of DatabaseInstaller for the specified DB type. * @@ -486,15 +502,15 @@ abstract class Installer { $_lsExists = file_exists( "$IP/LocalSettings.php" ); wfRestoreWarnings(); - if( !$_lsExists ) { + if ( !$_lsExists ) { return false; } unset( $_lsExists ); - require( "$IP/includes/DefaultSettings.php" ); - require( "$IP/LocalSettings.php" ); + require "$IP/includes/DefaultSettings.php"; + require "$IP/LocalSettings.php"; if ( file_exists( "$IP/AdminSettings.php" ) ) { - require( "$IP/AdminSettings.php" ); + require "$IP/AdminSettings.php"; } return get_defined_vars(); } @@ -651,13 +667,7 @@ abstract class Installer { $allNames[] = wfMessage( "config-type-$name" )->text(); } - // cache initially available databases to make sure that everything will be displayed correctly - // after a refresh on env checks page - $databases = $this->getVar( '_CompiledDBs-preFilter' ); - if ( !$databases ) { - $databases = $this->getVar( '_CompiledDBs' ); - $this->setVar( '_CompiledDBs-preFilter', $databases ); - } + $databases = $this->getCompiledDBs(); $databases = array_flip ( $databases ); foreach ( array_keys( $databases ) as $db ) { @@ -676,7 +686,6 @@ abstract class Installer { // @todo FIXME: This only works for the web installer! return false; } - $this->setVar( '_CompiledDBs', $databases ); return true; } @@ -684,7 +693,7 @@ abstract class Installer { * Environment check for register_globals. */ protected function envCheckRegisterGlobals() { - if( wfIniGetBool( 'register_globals' ) ) { + if ( wfIniGetBool( 'register_globals' ) ) { $this->showMessage( 'config-register-globals' ); } } @@ -722,7 +731,7 @@ abstract class Installer { * @return bool */ protected function envCheckMagicQuotes() { - if( wfIniGetBool( "magic_quotes_runtime" ) ) { + if ( wfIniGetBool( "magic_quotes_runtime" ) ) { $this->showError( 'config-magic-quotes-runtime' ); return false; } @@ -830,10 +839,10 @@ abstract class Installer { $n = wfShorthandToInteger( $limit ); - if( $n < $this->minMemorySize * 1024 * 1024 ) { + if ( $n < $this->minMemorySize * 1024 * 1024 ) { $newLimit = "{$this->minMemorySize}M"; - if( ini_set( "memory_limit", $newLimit ) === false ) { + if ( ini_set( "memory_limit", $newLimit ) === false ) { $this->showMessage( 'config-memory-bad', $limit ); } else { $this->showMessage( 'config-memory-raised', $limit, $newLimit ); @@ -970,6 +979,7 @@ abstract class Installer { /** * Environment check for setting the preferred PHP file extension. + * @return bool */ protected function envCheckExtension() { // @todo FIXME: Detect this properly @@ -983,7 +993,7 @@ abstract class Installer { } /** - * TODO: document + * Environment check for preferred locale in shell * @return bool */ protected function envCheckShellLocale() { @@ -1002,7 +1012,7 @@ abstract class Installer { return true; } - $lines = wfArrayMap( 'trim', explode( "\n", $lines ) ); + $lines = array_map( 'trim', explode( "\n", $lines ) ); $candidatesByLocale = array(); $candidatesByLang = array(); @@ -1057,7 +1067,7 @@ abstract class Installer { } /** - * TODO: document + * Environment check for the permissions of the uploads directory * @return bool */ protected function envCheckUploadsDirectory() { @@ -1074,22 +1084,16 @@ abstract class Installer { } /** - * Checks if suhosin.get.max_value_length is set, and if so, sets - * $wgResourceLoaderMaxQueryLength to that value in the generated - * LocalSettings file + * Checks if suhosin.get.max_value_length is set, and if so generate + * a warning because it decreases ResourceLoader performance. * @return bool */ protected function envCheckSuhosinMaxValueLength() { $maxValueLength = ini_get( 'suhosin.get.max_value_length' ); - if ( $maxValueLength > 0 ) { - if( $maxValueLength < 1024 ) { - # Only warn if the value is below the sane 1024 - $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength ); - } - } else { - $maxValueLength = -1; + if ( $maxValueLength > 0 && $maxValueLength < 1024 ) { + // Only warn if the value is below the sane 1024 + $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength ); } - $this->setVar( 'wgResourceLoaderMaxQueryLength', $maxValueLength ); return true; } @@ -1140,14 +1144,14 @@ abstract class Installer { * We're going to prefer the pecl extension here unless * utf8_normalize is more up to date. */ - if( $utf8 ) { + if ( $utf8 ) { $useNormalizer = 'utf8'; $utf8 = utf8_normalize( $not_normal_c, UtfNormal::UNORM_NFC ); if ( $utf8 !== $normal_c ) { $needsUpdate = true; } } - if( $intl ) { + if ( $intl ) { $useNormalizer = 'intl'; $intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C ); if ( $intl !== $normal_c ) { @@ -1156,11 +1160,11 @@ abstract class Installer { } // Uses messages 'config-unicode-using-php', 'config-unicode-using-utf8', 'config-unicode-using-intl' - if( $useNormalizer === 'php' ) { + if ( $useNormalizer === 'php' ) { $this->showMessage( 'config-unicode-pure-php-warning' ); } else { $this->showMessage( 'config-unicode-using-' . $useNormalizer ); - if( $needsUpdate ) { + if ( $needsUpdate ) { $this->showMessage( 'config-unicode-update-warning' ); } } @@ -1243,9 +1247,9 @@ abstract class Installer { * @return bool|string */ public static function locateExecutableInDefaultPaths( $names, $versionInfo = false ) { - foreach( self::getPossibleBinPaths() as $path ) { + foreach ( self::getPossibleBinPaths() as $path ) { $exe = self::locateExecutable( $path, $names, $versionInfo ); - if( $exe !== false ) { + if ( $exe !== false ) { return $exe; } } @@ -1283,7 +1287,7 @@ abstract class Installer { try { $text = Http::get( $url . $file, array( 'timeout' => 3 ) ); } - catch( MWException $e ) { + catch ( MWException $e ) { // Http::get throws with allow_url_fopen = false and no curl extension. $text = null; } @@ -1344,7 +1348,7 @@ abstract class Installer { * @return array */ public function findExtensions() { - if( $this->getVar( 'IP' ) === null ) { + if ( $this->getVar( 'IP' ) === null ) { return array(); } @@ -1356,10 +1360,10 @@ abstract class Installer { $dh = opendir( $extDir ); $exts = array(); while ( ( $file = readdir( $dh ) ) !== false ) { - if( !is_dir( "$extDir/$file" ) ) { + if ( !is_dir( "$extDir/$file" ) ) { continue; } - if( file_exists( "$extDir/$file/$file.php" ) ) { + if ( file_exists( "$extDir/$file/$file.php" ) ) { $exts[] = $file; } } @@ -1390,10 +1394,10 @@ abstract class Installer { global $wgAutoloadClasses; $wgAutoloadClasses = array(); - require( "$IP/includes/DefaultSettings.php" ); + require "$IP/includes/DefaultSettings.php"; - foreach( $exts as $e ) { - require_once( "$IP/extensions/$e/$e.php" ); + foreach ( $exts as $e ) { + require_once "$IP/extensions/$e/$e.php"; } $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ? @@ -1431,9 +1435,9 @@ abstract class Installer { // Build the array of install steps starting from the core install list, // then adding any callbacks that wanted to attach after a given step - foreach( $coreInstallSteps as $step ) { + foreach ( $coreInstallSteps as $step ) { $this->installSteps[] = $step; - if( isset( $this->extraInstallSteps[$step['name']] ) ) { + if ( isset( $this->extraInstallSteps[$step['name']] ) ) { $this->installSteps = array_merge( $this->installSteps, $this->extraInstallSteps[$step['name']] @@ -1442,7 +1446,7 @@ abstract class Installer { } // Prepend any steps that want to be at the beginning - if( isset( $this->extraInstallSteps['BEGINNING'] ) ) { + if ( isset( $this->extraInstallSteps['BEGINNING'] ) ) { $this->installSteps = array_merge( $this->extraInstallSteps['BEGINNING'], $this->installSteps @@ -1450,7 +1454,7 @@ abstract class Installer { } // Extensions should always go first, chance to tie into hooks and such - if( count( $this->getVar( '_Extensions' ) ) ) { + if ( count( $this->getVar( '_Extensions' ) ) ) { array_unshift( $this->installSteps, array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) ) ); @@ -1475,7 +1479,7 @@ abstract class Installer { $installer = $this->getDBInstaller(); $installer->preInstall(); $steps = $this->getInstallSteps( $installer ); - foreach( $steps as $stepObj ) { + foreach ( $steps as $stepObj ) { $name = $stepObj['name']; call_user_func_array( $startCB, array( $name ) ); @@ -1488,11 +1492,11 @@ abstract class Installer { // If we've hit some sort of fatal, we need to bail. // Callback already had a chance to do output above. - if( !$status->isOk() ) { + if ( !$status->isOk() ) { break; } } - if( $status->isOk() ) { + if ( $status->isOk() ) { $this->setVar( '_InstallDone', true ); } return $installResults; @@ -1560,13 +1564,13 @@ abstract class Installer { try { $user->setPassword( $this->getVar( '_AdminPassword' ) ); - } catch( PasswordError $pwe ) { + } catch ( PasswordError $pwe ) { return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() ); } $user->addGroup( 'sysop' ); $user->addGroup( 'bureaucrat' ); - if( $this->getVar( '_AdminEmail' ) ) { + if ( $this->getVar( '_AdminEmail' ) ) { $user->setEmail( $this->getVar( '_AdminEmail' ) ); } $user->saveSettings(); @@ -1577,7 +1581,7 @@ abstract class Installer { } $status = Status::newGood(); - if( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) { + if ( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) { $this->subscribeToMediaWikiAnnounce( $status ); } @@ -1589,23 +1593,23 @@ abstract class Installer { */ private function subscribeToMediaWikiAnnounce( Status $s ) { $params = array( - 'email' => $this->getVar( '_AdminEmail' ), + 'email' => $this->getVar( '_AdminEmail' ), 'language' => 'en', - 'digest' => 0 + 'digest' => 0 ); // Mailman doesn't support as many languages as we do, so check to make // sure their selected language is available $myLang = $this->getVar( '_UserLang' ); - if( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) { + if ( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) { $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR $params['language'] = $myLang; } - if( MWHttpRequest::canMakeRequests() ) { + if ( MWHttpRequest::canMakeRequests() ) { $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl, array( 'method' => 'POST', 'postData' => $params ) )->execute(); - if( !$res->isOK() ) { + if ( !$res->isOK() ) { $s->warning( 'config-install-subscribe-fail', $res->getMessage() ); } } else {