abstract class Installer {
// This is the absolute minimum PHP version we can support
- const MINIMUM_PHP_VERSION = '5.2.0';
+ const MINIMUM_PHP_VERSION = '5.2.3';
/**
* @var array
'postgres',
'oracle',
'sqlite',
+ 'ibm_db2',
);
/**
'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/',
'icon' => '{$wgStylePath}/common/images/cc-by-nc-sa.png',
),
+ 'cc-0' => array(
+ 'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
+ 'icon' => '{$wgStylePath}/common/images/cc-0.png',
+ ),
'pd' => array(
'url' => 'http://creativecommons.org/licenses/publicdomain/',
'icon' => '{$wgStylePath}/common/images/public-domain.png',
* Constructor, always call this from child classes.
*/
public function __construct() {
- global $wgExtensionMessagesFiles, $wgUser, $wgHooks;
+ global $wgExtensionMessagesFiles, $wgUser;
// Disable the i18n cache and LoadBalancer
Language::getLocalisationCache()->disableBackend();
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId( 0 );
- // Set our custom <doclink> hook.
- $wgHooks['ParserFirstCallInit'][] = array( $this, 'registerDocLink' );
-
$this->settings = $this->internalDefaults;
foreach ( $this->defaultVarNames as $var ) {
$allNames = array();
foreach ( self::getDBTypes() as $name ) {
- $db = $this->getDBInstaller( $name );
- $readableName = wfMsg( 'config-type-' . $name );
-
- if ( $db->isCompiled() ) {
+ if ( $this->getDBInstaller( $name )->isCompiled() ) {
$compiledDBs[] = $name;
}
- $allNames[] = $readableName;
+ $allNames[] = wfMsg( 'config-type-' . $name );
}
$this->setVar( '_CompiledDBs', $compiledDBs );
// Check for FTS3 full-text search module
$sqlite = $this->getDBInstaller( 'sqlite' );
if ( $sqlite->isCompiled() ) {
- $db = new DatabaseSqliteStandalone( ':memory:' );
- if( $db->getFulltextSearchModule() != 'FTS3' ) {
+ if( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) {
$this->showMessage( 'config-no-fts3' );
}
}
$names = array( wfIsWindows() ? 'convert.exe' : 'convert' );
$convert = self::locateExecutableInDefaultPaths( $names, array( '$1 -version', 'ImageMagick' ) );
+ $this->setVar( 'wgImageMagickConvertCommand', '' );
if ( $convert ) {
$this->setVar( 'wgImageMagickConvertCommand', $convert );
$this->showMessage( 'config-imagemagick', $convert );
$this->showMessage( 'config-gd' );
return true;
} else {
- $this->showMessage( 'no-scaling' );
+ $this->showMessage( 'config-no-scaling' );
}
}
return false;
}
- /**
- * Register tag hook below.
- *
- * @todo Move this to WebInstaller with the two things below?
- *
- * @param $parser Parser
- */
- public function registerDocLink( Parser &$parser ) {
- $parser->setHook( 'doclink', array( $this, 'docLink' ) );
- return true;
- }
-
/**
* ParserOptions are constructed before we determined the language, so fix it
*/
$this->parserOptions->setUserLang( $lang->getCode() );
}
- /**
- * Extension tag hook for a documentation link.
- */
- public function docLink( $linkText, $attribs, $parser ) {
- $url = $this->getDocUrl( $attribs['href'] );
- return '<a href="' . htmlspecialchars( $url ) . '">' .
- htmlspecialchars( $linkText ) .
- '</a>';
- }
-
/**
* Overridden by WebInstaller to provide lastPage parameters.
*/
* but we're not opening that can of worms
* @see https://bugzilla.wikimedia.org/show_bug.cgi?id=26857
*/
- global $wgHooks, $wgAutoloadClasses;
+ global $wgAutoloadClasses;
+ $wgAutoloadClasses = array();
+
require( "$IP/includes/DefaultSettings.php" );
foreach( $exts as $e ) {
- require( "$path/$e/$e.php" );
+ require_once( "$path/$e/$e.php" );
}
$hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
// Unset everyone else's hooks. Lord knows what someone might be doing
// in ParserFirstCallInit (see bug 27171)
- unset( $wgHooks );
- $wgHooks = array( 'LoadExtensionSchemaUpdates' => $hooksWeWant );
+ $GLOBALS['wgHooks'] = array( 'LoadExtensionSchemaUpdates' => $hooksWeWant );
return Status::newGood();
}
array( 'name' => 'tables', 'callback' => array( $installer, 'createTables' ) ),
array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
array( 'name' => 'stats', 'callback' => array( $this, 'populateSiteStats' ) ),
- array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ),
- array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ),
+ array( 'name' => 'keys', 'callback' => array( $this, 'generateKeys' ) ),
array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
);
*
* @return Status
*/
- protected function generateSecretKey() {
- return $this->generateSecret( 'wgSecretKey' );
+ public function generateKeys() {
+ $keys = array( 'wgSecretKey' => 64 );
+ if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
+ $keys['wgUpgradeKey'] = 16;
+ }
+ return $this->doGenerateKeys( $keys );
}
/**
- * Generate a secret value for a variable using either
- * /dev/urandom or mt_rand() Produce a warning in the later case.
+ * Generate a secret value for variables using either
+ * /dev/urandom or mt_rand(). Produce a warning in the later case.
*
+ * @param $keys Array
* @return Status
*/
- protected function generateSecret( $secretName, $length = 64 ) {
- if ( wfIsWindows() ) {
- $file = null;
- } else {
- wfSuppressWarnings();
- $file = fopen( "/dev/urandom", "r" );
- wfRestoreWarnings();
- }
-
+ protected function doGenerateKeys( $keys ) {
$status = Status::newGood();
- if ( $file ) {
- $secretKey = bin2hex( fread( $file, $length / 2 ) );
- fclose( $file );
- } else {
- $secretKey = '';
+ wfSuppressWarnings();
+ $file = fopen( "/dev/urandom", "r" );
+ wfRestoreWarnings();
- for ( $i = 0; $i < $length / 8; $i++ ) {
- $secretKey .= dechex( mt_rand( 0, 0x7fffffff ) );
+ foreach ( $keys as $name => $length ) {
+ if ( $file ) {
+ $secretKey = bin2hex( fread( $file, $length / 2 ) );
+ } else {
+ $secretKey = '';
+
+ for ( $i = 0; $i < $length / 8; $i++ ) {
+ $secretKey .= dechex( mt_rand( 0, 0x7fffffff ) );
+ }
}
- $status->warning( 'config-insecure-secret', '$' . $secretName );
+ $this->setVar( $name, $secretKey );
}
- $this->setVar( $secretName, $secretKey );
+ if ( $file ) {
+ fclose( $file );
+ } else {
+ $names = array_keys ( $keys );
+ $names = preg_replace( '/^(.*)$/', '\$$1', $names );
+ global $wgLang;
+ $status->warning( 'config-insecure-keys', $wgLang->listToText( $names ), count( $names ) );
+ }
return $status;
}
- /**
- * Generate a default $wgUpgradeKey. Will warn if we had to use
- * mt_rand() instead of /dev/urandom
- *
- * @return Status
- */
- public function generateUpgradeKey() {
- if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
- return $this->generateSecret( 'wgUpgradeKey', 16 );
- }
- return Status::newGood();
- }
-
/**
* Create the first user account, grant it sysop and bureaucrat rights
*