<?php
/**
- * Base installer class
- * Handles everything that is independent of user interface
+ * Base installer class.
+ * Handles everything that is independent of user interface.
*/
abstract class Installer {
- var $settings, $output;
+ public $settings;
+ public $output;
/**
* MediaWiki configuration globals that will eventually be passed through
);
/**
- * Minimum memory size in MB
+ * Minimum memory size in MB.
*/
private $minMemorySize = 50;
);
/**
- * Known object cache types and the functions used to test for their existence
+ * Known object cache types and the functions used to test for their existence.
*/
protected $objectCaches = array(
'xcache' => 'xcache_get',
);
/**
- * User rights profiles
+ * User rights profiles.
*/
- var $rightsProfiles = array(
+ public $rightsProfiles = array(
'wiki' => array(),
'no-anon' => array(
'*' => array( 'edit' => false )
);
/**
- * License types
+ * License types.
*/
- var $licenses = array(
+ public $licenses = array(
'none' => array(
'url' => '',
'icon' => '',
/**
* Constructor, always call this from child classes
*/
- function __construct() {
+ public function __construct() {
// Disable the i18n cache and LoadBalancer
Language::getLocalisationCache()->disableBackend();
LBFactory::disableBackend();
* The messages will be in wikitext format, which will be converted to an
* output format such as HTML or text before being sent to the user.
*/
- abstract function showMessage( $msg /*, ... */ );
+ public abstract function showMessage( $msg /*, ... */ );
- abstract function showStatusMessage( $status );
+ public abstract function showStatusMessage( $status );
/**
- * Get a list of known DB types
+ * Get a list of known DB types.
*/
- function getDBTypes() {
+ public function getDBTypes() {
return $this->dbTypes;
}
/**
* Get an instance of InstallerDBType for the specified DB type
- * @param $type Mixed: DB installer for which is needed, false to use default
+ * @param $type Mixed: DB installer for which is needed, false to use default.
*/
- function getDBInstaller( $type = false ) {
+ public function getDBInstaller( $type = false ) {
if ( !$type ) {
$type = $this->getVar( 'wgDBtype' );
}
* Under the web subclass, it can already be assumed that PHP 5+ is in use
* and that sessions are working.
*/
- function doEnvironmentChecks() {
+ public function doEnvironmentChecks() {
$this->showMessage( 'config-env-php', phpversion() );
$good = true;
* The defaults come from $GLOBALS (ultimately DefaultSettings.php).
* Installer variables are typically prefixed by an underscore.
*/
- function getVar( $name, $default = null ) {
+ public function getVar( $name, $default = null ) {
if ( !isset( $this->settings[$name] ) ) {
return $default;
} else {
/**
* Set a MW configuration variable, or internal installer configuration variable.
*/
- function setVar( $name, $value ) {
+ public function setVar( $name, $value ) {
$this->settings[$name] = $value;
}
/**
* Exports all wg* variables stored by the installer into global scope
*/
- function exportVars() {
+ public function exportVars() {
foreach ( $this->settings as $name => $value ) {
if ( substr( $name, 0, 2 ) == 'wg' ) {
$GLOBALS[$name] = $value;
* This is a security mechanism to avoid compromise of the password in the
* event of session ID compromise.
*/
- function getFakePassword( $realPassword ) {
+ public function getFakePassword( $realPassword ) {
return str_repeat( '*', strlen( $realPassword ) );
}
* Set a variable which stores a password, except if the new value is a
* fake password in which case leave it as it is.
*/
- function setPassword( $name, $value ) {
+ public function setPassword( $name, $value ) {
if ( !preg_match( '/^\*+$/', $value ) ) {
$this->setVar( $name, $value );
}
}
/** Check if we're installing the latest version */
- function envLatestVersion() {
+ public function envLatestVersion() {
global $wgVersion;
$latestInfoUrl = 'http://www.mediawiki.org/w/api.php?action=mwreleases&format=json';
$latestInfo = Http::get( $latestInfoUrl );
}
/** Environment check for DB types */
- function envCheckDB() {
+ public function envCheckDB() {
$compiledDBs = array();
$goodNames = array();
$allNames = array();
}
/** Environment check for register_globals */
- function envCheckRegisterGlobals() {
+ public function envCheckRegisterGlobals() {
if( wfIniGetBool( "magic_quotes_runtime" ) ) {
$this->showMessage( 'config-register-globals' );
}
}
/** Environment check for magic_quotes_runtime */
- function envCheckMagicQuotes() {
+ public function envCheckMagicQuotes() {
if( wfIniGetBool( "magic_quotes_runtime" ) ) {
$this->showMessage( 'config-magic-quotes-runtime' );
return false;
}
/** Environment check for magic_quotes_sybase */
- function envCheckMagicSybase() {
+ public function envCheckMagicSybase() {
if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
$this->showMessage( 'config-magic-quotes-sybase' );
return false;
}
/* Environment check for mbstring.func_overload */
- function envCheckMbstring() {
+ public function envCheckMbstring() {
if ( wfIniGetBool( 'mbstring.func_overload' ) ) {
$this->showMessage( 'config-mbstring' );
return false;
}
/** Environment check for zend.ze1_compatibility_mode */
- function envCheckZE1() {
+ public function envCheckZE1() {
if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) {
$this->showMessage( 'config-ze1' );
return false;
}
/** Environment check for safe_mode */
- function envCheckSafeMode() {
+ public function envCheckSafeMode() {
if ( wfIniGetBool( 'safe_mode' ) ) {
$this->setVar( '_SafeMode', true );
$this->showMessage( 'config-safe-mode' );
}
/** Environment check for the XML module */
- function envCheckXML() {
+ public function envCheckXML() {
if ( !function_exists( "utf8_encode" ) ) {
$this->showMessage( 'config-xml-bad' );
return false;
}
/** Environment check for the PCRE module */
- function envCheckPCRE() {
+ public function envCheckPCRE() {
if ( !function_exists( 'preg_match' ) ) {
$this->showMessage( 'config-pcre' );
return false;
}
/** Environment check for available memory */
- function envCheckMemory() {
+ public function envCheckMemory() {
$limit = ini_get( 'memory_limit' );
if ( !$limit || $limit == -1 ) {
$this->showMessage( 'config-memory-none' );
}
/** Environment check for compiled object cache types */
- function envCheckCache() {
+ public function envCheckCache() {
$caches = array();
foreach ( $this->objectCaches as $name => $function ) {
if ( function_exists( $function ) ) {
}
/** Search for GNU diff3 */
- function envCheckDiff3() {
+ public function envCheckDiff3() {
$paths = array_merge(
array(
"/usr/bin",
/**
* Search a path for any of the given executable names. Returns the
* executable name if found. Also checks the version string returned
- * by each executable
+ * by each executable.
*
* @param $path String: path to search
* @param $names Array of executable names
* If $versionInfo is not false, only executables with a version
* matching $versionInfo[1] will be returned.
*/
- function locateExecutable( $path, $names, $versionInfo = false ) {
+ public function locateExecutable( $path, $names, $versionInfo = false ) {
if (!is_array($names))
$names = array($names);
}
/** Environment check for ImageMagick and GD */
- function envCheckGraphics() {
+ public function envCheckGraphics() {
$imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
foreach( $imcheck as $dir ) {
$im = "$dir/convert";
}
/** Environment check for setting $IP and $wgScriptPath */
- function envCheckPath() {
+ public function envCheckPath() {
$IP = dirname( dirname( dirname( __FILE__ ) ) );
$this->setVar( 'IP', $IP );
$this->showMessage( 'config-dir', $IP );
}
/** Environment check for writable config/ directory */
- function envCheckWriteableDir() {
+ public function envCheckWriteableDir() {
$ipDir = $this->getVar( 'IP' );
$configDir = $ipDir . '/config';
if( !is_writeable( $configDir ) ) {
}
/** Environment check for setting the preferred PHP file extension */
- function envCheckExtension() {
+ public function envCheckExtension() {
// FIXME: detect this properly
if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
$ext = 'php5';
$this->showMessage( 'config-file-extension', $ext );
}
- function envCheckShellLocale() {
+ public function envCheckShellLocale() {
# Give up now if we're in safe mode or open_basedir
# It's theoretically possible but tricky to work with
if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) || !function_exists( 'exec' ) ) {
return true;
}
- function envCheckUploadsDirectory() {
+ public function envCheckUploadsDirectory() {
global $IP, $wgServer;
$dir = $IP . '/images/';
$url = $wgServer . $this->getVar( 'wgScriptPath' ) . '/images/';
}
/**
- * Checks if scripts located in the given directory can be executed via the given URL
+ * Checks if scripts located in the given directory can be executed via the given URL.
*/
- function dirIsExecutable( $dir, $url ) {
+ public function dirIsExecutable( $dir, $url ) {
$scriptTypes = array(
'php' => array(
"<?php echo 'ex' . 'ec';",
* @param $lineStart Boolean
* @return String
*/
- function parse( $text, $lineStart = false ) {
+ public function parse( $text, $lineStart = false ) {
global $wgParser;
try {
$out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
}
/**
- * Register tag hook below
+ * Register tag hook below.
*/
- function registerDocLink( &$parser ) {
+ public function registerDocLink( &$parser ) {
$parser->setHook( 'doclink', array( $this, 'docLink' ) );
return true;
}
/**
- * Extension tag hook for a documentation link
+ * Extension tag hook for a documentation link.
*/
- function docLink( $linkText, $attribs, $parser ) {
+ public function docLink( $linkText, $attribs, $parser ) {
$url = $this->getDocUrl( $attribs['href'] );
return '<a href="' . htmlspecialchars( $url ) . '">' .
htmlspecialchars( $linkText ) .
}
/**
- * Overridden by WebInstaller to provide lastPage parameters
+ * Overridden by WebInstaller to provide lastPage parameters.
*/
protected function getDocUrl( $page ) {
return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $attribs['href'] );
}
/**
- * Actually perform the installation
+ * Actually perform the installation.
* @param Array $startCB A callback array for the beginning of each step
* @param Array $endCB A callback array for the end of each step
* @return Array of Status objects
/**
* Determine if LocalSettings exists. If it does, return an appropriate
- * status for whether we should can upgrade or not
+ * status for whether we should can upgrade or not.
* @return Status
*/
- function getLocalSettingsStatus() {
+ public function getLocalSettingsStatus() {
global $IP;
$status = Status::newGood();
}
# posix_getegid() *not* getmygid() because we want the group of the webserver,
- # not whoever owns the current script
+ # not whoever owns the current script.
$gid = posix_getegid();
$getpwuid = posix_getpwuid( $gid );
$group = $getpwuid["name"];
}
/**
- * Override the necessary bits of the config to run an installation
+ * Override the necessary bits of the config to run an installation.
*/
public static function overrideConfig() {
define( 'MW_NO_SESSION', 1 );
* @param $findStep String the step to find. Use NULL to put the step at the beginning.
* @param $callback array
*/
- function addInstallStepFollowing( $findStep, $callback ) {
+ public function addInstallStepFollowing( $findStep, $callback ) {
$where = 0;
if( $findStep !== null ) $where = array_search( $findStep, $this->installSteps );
array_splice( $this->installSteps, $where, 0, $callback );
}
-
-}
+}
\ No newline at end of file