abstract class Installer {
// This is the absolute minimum PHP version we can support
- // @deprecated since 1.18
- const MINIMUM_PHP_VERSION = MW_MIN_PHP_VERSION;
+ const MINIMUM_PHP_VERSION = '5.2.3';
/**
* @var array
'envCheckCache',
'envCheckDiff3',
'envCheckGraphics',
+ 'envCheckServer',
'envCheckPath',
'envCheckExtension',
'envCheckShellLocale',
'wgDiff3',
'wgImageMagickConvertCommand',
'IP',
+ 'wgServer',
'wgScriptPath',
'wgScriptExtension',
'wgMetaNamespace',
'_UpgradeDone' => false,
'_InstallDone' => false,
'_Caches' => array(),
- '_InstallUser' => 'root',
'_InstallPassword' => '',
'_SameAccount' => true,
'_CreateDBAccount' => false,
* @var array
*/
public $licenses = array(
+ 'cc-by' => array(
+ 'url' => 'http://creativecommons.org/licenses/by/3.0/',
+ 'icon' => '{$wgStylePath}/common/images/cc-by.png',
+ ),
'cc-by-sa' => array(
'url' => 'http://creativecommons.org/licenses/by-sa/3.0/',
'icon' => '{$wgStylePath}/common/images/cc-by-sa.png',
'icon' => '{$wgStylePath}/common/images/cc-0.png',
),
'pd' => array(
- 'url' => 'http://creativecommons.org/licenses/publicdomain/',
+ 'url' => '',
'icon' => '{$wgStylePath}/common/images/public-domain.png',
),
- 'gfdl-old' => array(
- 'url' => 'http://www.gnu.org/licenses/old-licenses/fdl-1.2.html',
- 'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
- ),
- 'gfdl-current' => array(
+ 'gfdl' => array(
'url' => 'http://www.gnu.org/copyleft/fdl.html',
'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
),
*/
public function doEnvironmentChecks() {
$phpVersion = phpversion();
- if( version_compare( $phpVersion, MW_MIN_PHP_VERSION, '>=' ) ) {
+ if( version_compare( $phpVersion, self::MINIMUM_PHP_VERSION, '>=' ) ) {
$this->showMessage( 'config-env-php', $phpVersion );
$good = true;
} else {
- $this->showMessage( 'config-env-php-toolow', $phpVersion, MW_MIN_PHP_VERSION );
+ $this->showMessage( 'config-env-php-toolow', $phpVersion, self::MINIMUM_PHP_VERSION );
$good = false;
}
*
* @return Array
*/
- public function getExistingLocalSettings() {
+ public static function getExistingLocalSettings() {
global $IP;
wfSuppressWarnings();
if ( !$compiledDBs ) {
$this->showError( 'config-no-db', $wgLang->commaList( $allNames ) );
- // FIXME: this only works for the web installer!
+ // @todo FIXME: This only works for the web installer!
return false;
}
}
}
+ /**
+ * Environment check for the server hostname.
+ */
+ protected function envCheckServer() {
+ $server = WebRequest::detectServer();
+ $this->showMessage( 'config-using-server', $server );
+ $this->setVar( 'wgServer', $server );
+ }
+
/**
* Environment check for setting $IP and $wgScriptPath.
*/
// PHP_SELF isn't available sometimes, such as when PHP is CGI but
// cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
// to get the path to the current script... hopefully it's reliable. SIGH
- if ( !empty( $_SERVER['PHP_SELF'] ) ) {
+ if ( $this->getVar( 'wgScriptPath' ) ) {
+ // Some kind soul has set it for us already (e.g. debconf)
+ return true;
+ } elseif ( !empty( $_SERVER['PHP_SELF'] ) ) {
$path = $_SERVER['PHP_SELF'];
} elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
$path = $_SERVER['SCRIPT_NAME'];
- } elseif ( $this->getVar( 'wgScriptPath' ) ) {
- // Some kind soul has set it for us already (e.g. debconf)
return true;
} else {
$this->showError( 'config-no-uri' );
* Environment check for setting the preferred PHP file extension.
*/
protected function envCheckExtension() {
- // FIXME: detect this properly
+ // @todo FIXME: Detect this properly
if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
$ext = 'php5';
} else {
* TODO: document
*/
protected function envCheckUploadsDirectory() {
- global $IP, $wgServer;
+ global $IP;
$dir = $IP . '/images/';
- $url = $wgServer . $this->getVar( 'wgScriptPath' ) . '/images/';
+ $url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/';
$safe = !$this->dirIsExecutable( $dir, $url );
if ( $safe ) {
$this->showMessage( 'config-uploads-not-safe', $dir );
}
}
-
+
/**
* Checks if suhosin.get.max_value_length is set, and if so, sets
* $wgResourceLoaderMaxQueryLength to that value in the generated
$c = hexdec($c);
if ($c <= 0x7F) {
return chr($c);
- } else if ($c <= 0x7FF) {
+ } elseif ($c <= 0x7FF) {
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
- } else if ($c <= 0xFFFF) {
+ } elseif ($c <= 0xFFFF) {
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
- } else if ($c <= 0x10FFFF) {
+ } elseif ($c <= 0x10FFFF) {
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
. chr(0x80 | $c >> 6 & 0x3F)
. chr(0x80 | $c & 0x3F);
break;
}
- $text = Http::get( $url . $file, array( 'timeout' => 3 ) );
+ try {
+ $text = Http::get( $url . $file, array( 'timeout' => 3 ) );
+ }
+ catch( MWException $e ) {
+ // Http::get throws with allow_url_fopen = false and no curl extension.
+ $text = null;
+ }
unlink( $dir . $file );
if ( $text == 'exec' ) {
/**
* ParserOptions are constructed before we determined the language, so fix it
+ *
+ * @param $lang Language
*/
public function setParserLanguage( $lang ) {
$this->parserOptions->setTargetLanguage( $lang );
}
$exts = array();
- $dir = $this->getVar( 'IP' ) . '/extensions';
- $dh = opendir( $dir );
+ $extDir = $this->getVar( 'IP' ) . '/extensions';
+ $dh = opendir( $extDir );
while ( ( $file = readdir( $dh ) ) !== false ) {
- if( file_exists( "$dir/$file/$file.php" ) ) {
+ if( !is_dir( "$extDir/$file" ) ) {
+ continue;
+ }
+ if( file_exists( "$extDir/$file/$file.php" ) ) {
$exts[] = $file;
}
}
global $IP;
$exts = $this->getVar( '_Extensions' );
$IP = $this->getVar( 'IP' );
- $path = $IP . '/extensions';
/**
* We need to include DefaultSettings before including extensions to avoid
*/
global $wgAutoloadClasses;
$wgAutoloadClasses = array();
-
+
require( "$IP/includes/DefaultSettings.php" );
foreach( $exts as $e ) {
- require_once( "$path/$e/$e.php" );
+ require_once( "$IP/extensions/$e/$e.php" );
}
$hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
$params['language'] = $myLang;
}
- $res = Http::post( $this->mediaWikiAnnounceUrl, array( 'postData' => $params ) );
- if( !$res ) {
- $s->warning( 'config-install-subscribe-fail' );
+ $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
+ array( 'method' => 'POST', 'postData' => $params ) )->execute();
+ if( !$res->isOK() ) {
+ $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
}
}
public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
$this->extraInstallSteps[$findStep][] = $callback;
}
+
+ /**
+ * Disable the time limit for execution.
+ * Some long-running pages (Install, Upgrade) will want to do this
+ */
+ protected function disableTimeLimit() {
+ wfSuppressWarnings();
+ set_time_limit( 0 );
+ wfRestoreWarnings();
+ }
}