* These may output warnings using showMessage(), and/or abort the
* installation process by returning false.
*
+ * For the WebInstaller these are only called on the Welcome page,
+ * if these methods have side-effects that should affect later page loads
+ * (as well as the generated stylesheet), use envPreps instead.
+ *
* @var array
*/
protected $envChecks = array(
'envCheckRegisterGlobals',
'envCheckBrokenXML',
'envCheckMagicQuotes',
- 'envCheckMagicSybase',
'envCheckMbstring',
'envCheckSafeMode',
'envCheckXML',
'envCheckGit',
'envCheckServer',
'envCheckPath',
- 'envCheckExtension',
'envCheckShellLocale',
'envCheckUploadsDirectory',
'envCheckLibicu',
'envCheckSuhosinMaxValueLength',
'envCheckCtype',
+ 'envCheckIconv',
'envCheckJSON',
);
+ /**
+ * A list of environment preparation methods called by doEnvironmentPreps().
+ *
+ * @var array
+ */
+ protected $envPreps = array(
+ 'envPrepExtension',
+ 'envPrepServer',
+ 'envPrepPath',
+ );
+
/**
* MediaWiki configuration globals that will eventually be passed through
* to LocalSettings.php. The names only are given here, the defaults
'_LicenseCode' => 'none',
'_CCDone' => false,
'_Extensions' => array(),
+ '_Skins' => array(),
'_MemCachedServers' => '',
'_UpgradeKeySupplied' => false,
'_ExistingDBSettings' => false,
abstract public function showError( $msg /*, ... */ );
/**
- * Show a message to the installing user by using a Status object
+ * Shows messages to the user through a Status object
* @param Status $status
*/
- abstract public function showStatusMessage( Status $status );
+ public function showStatusMessage( Status $status ) {
+ $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
+ if ( $errors ) {
+ foreach ( $errors as $error ) {
+ call_user_func( 'showMessage', $error );
+ }
+ }
+ }
/**
* Constructor, always call this from child classes.
$this->settings[$var] = $GLOBALS[$var];
}
+ $this->doEnvironmentPreps();
+
$this->compiledDBs = array();
foreach ( self::getDBTypes() as $type ) {
$installer = $this->getDBInstaller( $type );
public function doEnvironmentChecks() {
// Php version has already been checked by entry scripts
// Show message here for information purposes
- $this->showMessage( 'config-env-php', phpversion() );
+ $this->showMessage( 'config-env-php', PHP_VERSION );
$good = true;
// Must go here because an old version of PCRE can prevent other checks from completing
return $good ? Status::newGood() : Status::newFatal( 'config-env-bad' );
}
+ public function doEnvironmentPreps() {
+ foreach ( $this->envPreps as $prep ) {
+ $this->$prep();
+ }
+ }
+
/**
* Set a MW configuration variable, or internal installer configuration variable.
*
}
/**
- * Environment check for magic_quotes_runtime.
+ * Environment check for magic_quotes_(gpc|runtime|sybase).
* @return bool
*/
protected function envCheckMagicQuotes() {
- if ( wfIniGetBool( "magic_quotes_runtime" ) ) {
- $this->showError( 'config-magic-quotes-runtime' );
-
- return false;
- }
-
- return true;
- }
-
- /**
- * Environment check for magic_quotes_sybase.
- * @return bool
- */
- protected function envCheckMagicSybase() {
- if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
- $this->showError( 'config-magic-quotes-sybase' );
-
- return false;
+ $status = true;
+ foreach ( array( 'gpc', 'runtime', 'sybase' ) as $magicJunk ) {
+ if ( wfIniGetBool( "magic_quotes_$magicJunk" ) ) {
+ $this->showError( "config-magic-quotes-$magicJunk" );
+ $status = false;
+ }
}
- return true;
+ return $status;
}
/**
}
/**
- * Environment check for the server hostname.
+ * Environment check to inform user which server we've assumed.
+ *
+ * @return bool
*/
protected function envCheckServer() {
$server = $this->envGetDefaultServer();
if ( $server !== null ) {
$this->showMessage( 'config-using-server', $server );
- $this->setVar( 'wgServer', $server );
}
-
return true;
}
/**
- * Helper function to be called from envCheckServer()
- * @return string
- */
- abstract protected function envGetDefaultServer();
-
- /**
- * Environment check for setting $IP and $wgScriptPath.
+ * Environment check to inform user which paths we've assumed.
+ *
* @return bool
*/
protected function envCheckPath() {
- global $IP;
- $IP = dirname( dirname( __DIR__ ) );
- $this->setVar( 'IP', $IP );
-
$this->showMessage(
'config-using-uri',
$this->getVar( 'wgServer' ),
$this->getVar( 'wgScriptPath' )
);
-
- return true;
- }
-
- /**
- * Environment check for setting the preferred PHP file extension.
- * @return bool
- */
- protected function envCheckExtension() {
- // @todo FIXME: Detect this properly
- if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
- $ext = 'php5';
- } else {
- $ext = 'php';
- }
- $this->setVar( 'wgScriptExtension', ".$ext" );
-
return true;
}
return true;
}
+ /**
+ * @return bool
+ */
+ protected function envCheckIconv() {
+ if ( !function_exists( 'iconv' ) ) {
+ $this->showError( 'config-iconv' );
+
+ return false;
+ }
+
+ return true;
+ }
+
/**
* @return bool
*/
return true;
}
+ /**
+ * Environment prep for the server hostname.
+ */
+ protected function envPrepServer() {
+ $server = $this->envGetDefaultServer();
+ if ( $server !== null ) {
+ $this->setVar( 'wgServer', $server );
+ }
+ }
+
+ /**
+ * Helper function to be called from envPrepServer()
+ * @return string
+ */
+ abstract protected function envGetDefaultServer();
+
+ /**
+ * Environment prep for setting the preferred PHP file extension.
+ */
+ protected function envPrepExtension() {
+ // @todo FIXME: Detect this properly
+ if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
+ $ext = '.php5';
+ } else {
+ $ext = '.php';
+ }
+ $this->setVar( 'wgScriptExtension', $ext );
+ }
+
+ /**
+ * Environment prep for setting $IP and $wgScriptPath.
+ */
+ protected function envPrepPath() {
+ global $IP;
+ $IP = dirname( dirname( __DIR__ ) );
+ $this->setVar( 'IP', $IP );
+ }
+
/**
* Get an array of likely places we can find executables. Check a bunch
* of known Unix-like defaults, as well as the PATH environment variable
}
/**
- * Finds extensions that follow the format /extensions/Name/Name.php,
+ * Finds extensions that follow the format /$directory/Name/Name.php,
* and returns an array containing the value for 'Name' for each found extension.
*
+ * Reasonable values for $directory include 'extensions' (the default) and 'skins'.
+ *
+ * @param string $directory Directory to search in
* @return array
*/
- public function findExtensions() {
+ public function findExtensions( $directory = 'extensions' ) {
if ( $this->getVar( 'IP' ) === null ) {
return array();
}
- $extDir = $this->getVar( 'IP' ) . '/extensions';
+ $extDir = $this->getVar( 'IP' ) . '/' . $directory;
if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
return array();
}