2010-05-07 12:25:01 +00:00
|
|
|
<?php
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
|
|
|
|
* Base code for MediaWiki installer.
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Deployment
|
|
|
|
|
*/
|
2010-05-07 12:25:01 +00:00
|
|
|
|
2010-07-29 18:36:39 +00:00
|
|
|
/**
|
|
|
|
|
* This documentation group collects source code files with deployment functionality.
|
|
|
|
|
*
|
|
|
|
|
* @defgroup Deployment Deployment
|
|
|
|
|
*/
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-19 02:41:54 +00:00
|
|
|
* Base installer class.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* This class provides the base for installation and update functionality
|
|
|
|
|
* for both MediaWiki core and extensions.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-29 18:36:39 +00:00
|
|
|
* @ingroup Deployment
|
2010-07-22 17:58:26 +00:00
|
|
|
* @since 1.17
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
|
|
|
|
abstract class Installer {
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2011-03-04 13:58:40 +00:00
|
|
|
// This is the absolute minimum PHP version we can support
|
2011-03-14 10:42:07 +00:00
|
|
|
const MINIMUM_PHP_VERSION = '5.2.3';
|
2011-03-04 13:58:40 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-21 17:20:50 +00:00
|
|
|
* @var array
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2011-01-28 15:00:18 +00:00
|
|
|
protected $settings;
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-22 17:58:26 +00:00
|
|
|
* Cached DB installer instances, access using getDBInstaller().
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-21 17:20:50 +00:00
|
|
|
* @var array
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-22 17:58:26 +00:00
|
|
|
protected $dbInstallers = array();
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
/**
|
2010-07-19 02:41:54 +00:00
|
|
|
* Minimum memory size in MB.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-21 17:20:50 +00:00
|
|
|
* @var integer
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-29 18:18:03 +00:00
|
|
|
protected $minMemorySize = 50;
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-21 17:20:50 +00:00
|
|
|
* Cached Title, used by parse().
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* @var Title
|
2010-07-21 17:20:50 +00:00
|
|
|
*/
|
2010-07-22 17:58:26 +00:00
|
|
|
protected $parserTitle;
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Cached ParserOptions, used by parse().
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* @var ParserOptions
|
2010-07-29 18:18:03 +00:00
|
|
|
*/
|
|
|
|
|
protected $parserOptions;
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
2010-07-22 17:58:26 +00:00
|
|
|
* Known database types. These correspond to the class names <type>Installer,
|
|
|
|
|
* and are also MediaWiki database types valid for $wgDBtype.
|
|
|
|
|
*
|
|
|
|
|
* To add a new type, create a <type>Installer class and a Database<type>
|
|
|
|
|
* class, and add a config-type-<type> message to MessagesEn.php.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-21 17:20:50 +00:00
|
|
|
* @var array
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-08-15 18:55:08 +00:00
|
|
|
protected static $dbTypes = array(
|
2010-07-22 17:58:26 +00:00
|
|
|
'mysql',
|
|
|
|
|
'postgres',
|
2010-10-18 16:09:18 +00:00
|
|
|
'oracle',
|
2010-07-22 17:58:26 +00:00
|
|
|
'sqlite',
|
|
|
|
|
);
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-18 18:52:05 +00:00
|
|
|
* A list of environment check methods called by doEnvironmentChecks().
|
|
|
|
|
* These may output warnings using showMessage(), and/or abort the
|
2010-05-07 12:25:01 +00:00
|
|
|
* installation process by returning false.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-21 17:20:50 +00:00
|
|
|
* @var array
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-05 00:29:38 +00:00
|
|
|
protected $envChecks = array(
|
2010-05-07 12:25:01 +00:00
|
|
|
'envCheckDB',
|
|
|
|
|
'envCheckRegisterGlobals',
|
2010-11-06 22:16:19 +00:00
|
|
|
'envCheckBrokenXML',
|
|
|
|
|
'envCheckPHP531',
|
2010-05-07 12:25:01 +00:00
|
|
|
'envCheckMagicQuotes',
|
|
|
|
|
'envCheckMagicSybase',
|
|
|
|
|
'envCheckMbstring',
|
|
|
|
|
'envCheckZE1',
|
|
|
|
|
'envCheckSafeMode',
|
|
|
|
|
'envCheckXML',
|
|
|
|
|
'envCheckPCRE',
|
|
|
|
|
'envCheckMemory',
|
|
|
|
|
'envCheckCache',
|
|
|
|
|
'envCheckDiff3',
|
|
|
|
|
'envCheckGraphics',
|
|
|
|
|
'envCheckPath',
|
|
|
|
|
'envCheckExtension',
|
|
|
|
|
'envCheckShellLocale',
|
|
|
|
|
'envCheckUploadsDirectory',
|
2010-07-29 02:44:23 +00:00
|
|
|
'envCheckLibicu'
|
2010-07-29 18:18:03 +00:00
|
|
|
);
|
|
|
|
|
|
2011-01-25 18:24:16 +00:00
|
|
|
/**
|
2011-01-21 15:27:16 +00:00
|
|
|
* MediaWiki configuration globals that will eventually be passed through
|
|
|
|
|
* to LocalSettings.php. The names only are given here, the defaults
|
|
|
|
|
* typically come from DefaultSettings.php.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $defaultVarNames = array(
|
|
|
|
|
'wgSitename',
|
|
|
|
|
'wgPasswordSender',
|
|
|
|
|
'wgLanguageCode',
|
|
|
|
|
'wgRightsIcon',
|
|
|
|
|
'wgRightsText',
|
|
|
|
|
'wgRightsUrl',
|
|
|
|
|
'wgMainCacheType',
|
|
|
|
|
'wgEnableEmail',
|
|
|
|
|
'wgEnableUserEmail',
|
|
|
|
|
'wgEnotifUserTalk',
|
|
|
|
|
'wgEnotifWatchlist',
|
|
|
|
|
'wgEmailAuthentication',
|
|
|
|
|
'wgDBtype',
|
|
|
|
|
'wgDiff3',
|
|
|
|
|
'wgImageMagickConvertCommand',
|
|
|
|
|
'IP',
|
|
|
|
|
'wgScriptPath',
|
|
|
|
|
'wgScriptExtension',
|
|
|
|
|
'wgMetaNamespace',
|
|
|
|
|
'wgDeletedDirectory',
|
|
|
|
|
'wgEnableUploads',
|
|
|
|
|
'wgLogo',
|
|
|
|
|
'wgShellLocale',
|
|
|
|
|
'wgSecretKey',
|
|
|
|
|
'wgUseInstantCommons',
|
|
|
|
|
'wgUpgradeKey',
|
|
|
|
|
'wgDefaultSkin',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Variables that are stored alongside globals, and are used for any
|
|
|
|
|
* configuration of the installation process aside from the MediaWiki
|
|
|
|
|
* configuration. Map of names to defaults.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $internalDefaults = array(
|
|
|
|
|
'_UserLang' => 'en',
|
|
|
|
|
'_Environment' => false,
|
|
|
|
|
'_CompiledDBs' => array(),
|
|
|
|
|
'_SafeMode' => false,
|
|
|
|
|
'_RaiseMemory' => false,
|
|
|
|
|
'_UpgradeDone' => false,
|
|
|
|
|
'_InstallDone' => false,
|
|
|
|
|
'_Caches' => array(),
|
|
|
|
|
'_InstallUser' => 'root',
|
|
|
|
|
'_InstallPassword' => '',
|
|
|
|
|
'_SameAccount' => true,
|
|
|
|
|
'_CreateDBAccount' => false,
|
|
|
|
|
'_NamespaceType' => 'site-name',
|
|
|
|
|
'_AdminName' => '', // will be set later, when the user selects language
|
|
|
|
|
'_AdminPassword' => '',
|
|
|
|
|
'_AdminPassword2' => '',
|
|
|
|
|
'_AdminEmail' => '',
|
|
|
|
|
'_Subscribe' => false,
|
|
|
|
|
'_SkipOptional' => 'continue',
|
|
|
|
|
'_RightsProfile' => 'wiki',
|
|
|
|
|
'_LicenseCode' => 'none',
|
|
|
|
|
'_CCDone' => false,
|
|
|
|
|
'_Extensions' => array(),
|
|
|
|
|
'_MemCachedServers' => '',
|
|
|
|
|
'_UpgradeKeySupplied' => false,
|
|
|
|
|
'_ExistingDBSettings' => false,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The actual list of installation steps. This will be initialized by getInstallSteps()
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
private $installSteps = array();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Extra steps for installation, for things like DatabaseInstallers to modify
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $extraInstallSteps = array();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Known object cache types and the functions used to test for their existence.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $objectCaches = array(
|
|
|
|
|
'xcache' => 'xcache_get',
|
|
|
|
|
'apc' => 'apc_fetch',
|
|
|
|
|
'eaccel' => 'eaccelerator_get',
|
|
|
|
|
'wincache' => 'wincache_ucache_get'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* User rights profiles.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
public $rightsProfiles = array(
|
|
|
|
|
'wiki' => array(),
|
|
|
|
|
'no-anon' => array(
|
|
|
|
|
'*' => array( 'edit' => false )
|
|
|
|
|
),
|
|
|
|
|
'fishbowl' => array(
|
|
|
|
|
'*' => array(
|
|
|
|
|
'createaccount' => false,
|
|
|
|
|
'edit' => false,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
'private' => array(
|
|
|
|
|
'*' => array(
|
|
|
|
|
'createaccount' => false,
|
|
|
|
|
'edit' => false,
|
|
|
|
|
'read' => false,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* License types.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
public $licenses = array(
|
|
|
|
|
'cc-by-sa' => array(
|
|
|
|
|
'url' => 'http://creativecommons.org/licenses/by-sa/3.0/',
|
|
|
|
|
'icon' => '{$wgStylePath}/common/images/cc-by-sa.png',
|
|
|
|
|
),
|
|
|
|
|
'cc-by-nc-sa' => array(
|
|
|
|
|
'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/',
|
|
|
|
|
'icon' => '{$wgStylePath}/common/images/cc-by-nc-sa.png',
|
|
|
|
|
),
|
2011-03-06 20:14:12 +00:00
|
|
|
'cc-0' => array(
|
|
|
|
|
'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
|
|
|
|
|
'icon' => '{$wgStylePath}/common/images/cc-0.png',
|
|
|
|
|
),
|
2011-01-21 15:27:16 +00:00
|
|
|
'pd' => array(
|
|
|
|
|
'url' => 'http://creativecommons.org/licenses/publicdomain/',
|
|
|
|
|
'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(
|
|
|
|
|
'url' => 'http://www.gnu.org/copyleft/fdl.html',
|
|
|
|
|
'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
|
|
|
|
|
),
|
|
|
|
|
'none' => array(
|
|
|
|
|
'url' => '',
|
|
|
|
|
'icon' => '',
|
|
|
|
|
'text' => ''
|
|
|
|
|
),
|
|
|
|
|
'cc-choose' => array(
|
|
|
|
|
// Details will be filled in by the selector.
|
|
|
|
|
'url' => '',
|
|
|
|
|
'icon' => '',
|
|
|
|
|
'text' => '',
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* URL to mediawiki-announce subscription
|
|
|
|
|
*/
|
|
|
|
|
protected $mediaWikiAnnounceUrl = 'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Supported language codes for Mailman
|
|
|
|
|
*/
|
|
|
|
|
protected $mediaWikiAnnounceLanguages = array(
|
|
|
|
|
'ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hr', 'hu',
|
|
|
|
|
'it', 'ja', 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru',
|
|
|
|
|
'sl', 'sr', 'sv', 'tr', 'uk'
|
|
|
|
|
);
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-22 17:58:26 +00:00
|
|
|
* UI interface for displaying a short message
|
|
|
|
|
* The parameters are like parameters to wfMsg().
|
|
|
|
|
* 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.
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-22 17:58:26 +00:00
|
|
|
public abstract function showMessage( $msg /*, ... */ );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2011-01-21 15:27:16 +00:00
|
|
|
/**
|
|
|
|
|
* Show a message to the installing user by using a Status object
|
|
|
|
|
* @param $status Status
|
|
|
|
|
*/
|
|
|
|
|
public abstract function showStatusMessage( Status $status );
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-22 17:58:26 +00:00
|
|
|
* Constructor, always call this from child classes.
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-29 18:18:03 +00:00
|
|
|
public function __construct() {
|
2011-03-24 21:35:14 +00:00
|
|
|
global $wgExtensionMessagesFiles, $wgUser;
|
2011-01-21 15:27:16 +00:00
|
|
|
|
2010-06-27 21:48:51 +00:00
|
|
|
// Disable the i18n cache and LoadBalancer
|
|
|
|
|
Language::getLocalisationCache()->disableBackend();
|
|
|
|
|
LBFactory::disableBackend();
|
2011-01-21 15:27:16 +00:00
|
|
|
|
|
|
|
|
// Load the installer's i18n file.
|
|
|
|
|
$wgExtensionMessagesFiles['MediawikiInstaller'] =
|
|
|
|
|
dirname( __FILE__ ) . '/Installer.i18n.php';
|
|
|
|
|
|
|
|
|
|
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
|
|
|
|
|
$wgUser = User::newFromId( 0 );
|
|
|
|
|
|
|
|
|
|
$this->settings = $this->internalDefaults;
|
|
|
|
|
|
|
|
|
|
foreach ( $this->defaultVarNames as $var ) {
|
|
|
|
|
$this->settings[$var] = $GLOBALS[$var];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ( self::getDBTypes() as $type ) {
|
|
|
|
|
$installer = $this->getDBInstaller( $type );
|
|
|
|
|
|
|
|
|
|
if ( !$installer->isCompiled() ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$defaults = $installer->getGlobalDefaults();
|
|
|
|
|
|
|
|
|
|
foreach ( $installer->getGlobalNames() as $var ) {
|
|
|
|
|
if ( isset( $defaults[$var] ) ) {
|
|
|
|
|
$this->settings[$var] = $defaults[$var];
|
|
|
|
|
} else {
|
|
|
|
|
$this->settings[$var] = $GLOBALS[$var];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->parserTitle = Title::newFromText( 'Installer' );
|
|
|
|
|
$this->parserOptions = new ParserOptions; // language will be wrong :(
|
|
|
|
|
$this->parserOptions->setEditSection( false );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-19 02:41:54 +00:00
|
|
|
* Get a list of known DB types.
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-08-15 18:55:08 +00:00
|
|
|
public static function getDBTypes() {
|
|
|
|
|
return self::$dbTypes;
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-18 18:52:05 +00:00
|
|
|
* Do initial checks of the PHP environment. Set variables according to
|
2010-05-07 12:25:01 +00:00
|
|
|
* the observed environment.
|
|
|
|
|
*
|
|
|
|
|
* It's possible that this may be called under the CLI SAPI, not the SAPI
|
|
|
|
|
* that the wiki will primarily run under. In that case, the subclass should
|
|
|
|
|
* initialise variables such as wgScriptPath, before calling this function.
|
|
|
|
|
*
|
2010-07-18 18:52:05 +00:00
|
|
|
* Under the web subclass, it can already be assumed that PHP 5+ is in use
|
2010-05-07 12:25:01 +00:00
|
|
|
* and that sessions are working.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2011-01-05 23:20:12 +00:00
|
|
|
* @return Status
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 02:41:54 +00:00
|
|
|
public function doEnvironmentChecks() {
|
2011-03-04 13:58:40 +00:00
|
|
|
$phpVersion = phpversion();
|
|
|
|
|
if( version_compare( $phpVersion, self::MINIMUM_PHP_VERSION, '>=' ) ) {
|
|
|
|
|
$this->showMessage( 'config-env-php', $phpVersion );
|
|
|
|
|
$good = true;
|
|
|
|
|
} else {
|
|
|
|
|
$this->showMessage( 'config-env-php-toolow', $phpVersion, self::MINIMUM_PHP_VERSION );
|
|
|
|
|
$good = false;
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2011-03-04 13:58:40 +00:00
|
|
|
if( $good ) {
|
|
|
|
|
foreach ( $this->envChecks as $check ) {
|
|
|
|
|
$status = $this->$check();
|
|
|
|
|
if ( $status === false ) {
|
|
|
|
|
$good = false;
|
|
|
|
|
}
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->setVar( '_Environment', $good );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2011-01-05 23:20:12 +00:00
|
|
|
return $good ? Status::newGood() : Status::newFatal( 'config-env-bad' );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
/**
|
|
|
|
|
* Set a MW configuration variable, or internal installer configuration variable.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* @param $name String
|
|
|
|
|
* @param $value Mixed
|
|
|
|
|
*/
|
|
|
|
|
public function setVar( $name, $value ) {
|
|
|
|
|
$this->settings[$name] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
|
|
|
|
* Get an MW configuration variable, or internal installer configuration variable.
|
|
|
|
|
* The defaults come from $GLOBALS (ultimately DefaultSettings.php).
|
|
|
|
|
* Installer variables are typically prefixed by an underscore.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* @param $name String
|
|
|
|
|
* @param $default Mixed
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* @return mixed
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 02:41:54 +00:00
|
|
|
public function getVar( $name, $default = null ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !isset( $this->settings[$name] ) ) {
|
|
|
|
|
return $default;
|
|
|
|
|
} else {
|
|
|
|
|
return $this->settings[$name];
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-22 17:58:26 +00:00
|
|
|
* Get an instance of DatabaseInstaller for the specified DB type.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* @param $type Mixed: DB installer for which is needed, false to use default.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* @return DatabaseInstaller
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-22 17:58:26 +00:00
|
|
|
public function getDBInstaller( $type = false ) {
|
|
|
|
|
if ( !$type ) {
|
|
|
|
|
$type = $this->getVar( 'wgDBtype' );
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
$type = strtolower( $type );
|
2010-05-07 12:25:01 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
if ( !isset( $this->dbInstallers[$type] ) ) {
|
|
|
|
|
$class = ucfirst( $type ). 'Installer';
|
|
|
|
|
$this->dbInstallers[$type] = new $class( $this );
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
return $this->dbInstallers[$type];
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-12-19 04:31:15 +00:00
|
|
|
* Determine if LocalSettings.php exists. If it does, return its variables,
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
* merged with those from AdminSettings.php, as an array.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
* @return Array
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
public function getExistingLocalSettings() {
|
2010-07-22 17:58:26 +00:00
|
|
|
global $IP;
|
|
|
|
|
|
|
|
|
|
wfSuppressWarnings();
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
$_lsExists = file_exists( "$IP/LocalSettings.php" );
|
2010-07-22 17:58:26 +00:00
|
|
|
wfRestoreWarnings();
|
|
|
|
|
|
2010-12-11 22:54:41 +00:00
|
|
|
if( !$_lsExists ) {
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
return false;
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-12-11 22:54:41 +00:00
|
|
|
unset($_lsExists);
|
|
|
|
|
|
|
|
|
|
require( "$IP/includes/DefaultSettings.php" );
|
|
|
|
|
require( "$IP/LocalSettings.php" );
|
|
|
|
|
if ( file_exists( "$IP/AdminSettings.php" ) ) {
|
|
|
|
|
require( "$IP/AdminSettings.php" );
|
|
|
|
|
}
|
|
|
|
|
return get_defined_vars();
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
|
|
|
|
* Get a fake password for sending back to the user in HTML.
|
|
|
|
|
* This is a security mechanism to avoid compromise of the password in the
|
|
|
|
|
* event of session ID compromise.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* @param $realPassword String
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* @return string
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 02:41:54 +00:00
|
|
|
public function getFakePassword( $realPassword ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
return str_repeat( '*', strlen( $realPassword ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-18 18:52:05 +00:00
|
|
|
* Set a variable which stores a password, except if the new value is a
|
2010-05-07 12:25:01 +00:00
|
|
|
* fake password in which case leave it as it is.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* @param $name String
|
|
|
|
|
* @param $value Mixed
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 02:41:54 +00:00
|
|
|
public function setPassword( $name, $value ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !preg_match( '/^\*+$/', $value ) ) {
|
|
|
|
|
$this->setVar( $name, $value );
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
2010-07-22 17:58:26 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* On POSIX systems return the primary group of the webserver we're running under.
|
|
|
|
|
* On other systems just returns null.
|
|
|
|
|
*
|
2011-02-26 12:35:23 +00:00
|
|
|
* This is used to advice the user that he should chgrp his mw-config/data/images directory as the
|
2010-07-22 17:58:26 +00:00
|
|
|
* webserver user before he can install.
|
|
|
|
|
*
|
|
|
|
|
* Public because SqliteInstaller needs it, and doesn't subclass Installer.
|
|
|
|
|
*
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public static function maybeGetWebserverPrimaryGroup() {
|
|
|
|
|
if ( !function_exists( 'posix_getegid' ) || !function_exists( 'posix_getpwuid' ) ) {
|
|
|
|
|
# I don't know this, this isn't UNIX.
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# posix_getegid() *not* getmygid() because we want the group of the webserver,
|
|
|
|
|
# not whoever owns the current script.
|
|
|
|
|
$gid = posix_getegid();
|
|
|
|
|
$getpwuid = posix_getpwuid( $gid );
|
|
|
|
|
$group = $getpwuid['name'];
|
|
|
|
|
|
|
|
|
|
return $group;
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
/**
|
|
|
|
|
* Convert wikitext $text to HTML.
|
|
|
|
|
*
|
|
|
|
|
* This is potentially error prone since many parser features require a complete
|
|
|
|
|
* installed MW database. The solution is to just not use those features when you
|
|
|
|
|
* write your messages. This appears to work well enough. Basic formatting and
|
|
|
|
|
* external links work just fine.
|
|
|
|
|
*
|
|
|
|
|
* But in case a translator decides to throw in a #ifexist or internal link or
|
2010-11-11 23:04:55 +00:00
|
|
|
* whatever, this function is guarded to catch the attempted DB access and to present
|
2010-07-22 17:58:26 +00:00
|
|
|
* some fallback text.
|
|
|
|
|
*
|
|
|
|
|
* @param $text String
|
|
|
|
|
* @param $lineStart Boolean
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
|
|
|
|
public function parse( $text, $lineStart = false ) {
|
|
|
|
|
global $wgParser;
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
try {
|
|
|
|
|
$out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
|
|
|
|
|
$html = $out->getText();
|
|
|
|
|
} catch ( DBAccessError $e ) {
|
|
|
|
|
$html = '<!--DB access attempted during parse--> ' . htmlspecialchars( $text );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
if ( !empty( $this->debug ) ) {
|
|
|
|
|
$html .= "<!--\n" . $e->getTraceAsString() . "\n-->";
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
return $html;
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-12-10 03:02:03 +00:00
|
|
|
public function getParserOptions() {
|
|
|
|
|
return $this->parserOptions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function disableLinkPopups() {
|
|
|
|
|
$this->parserOptions->setExternalLinkTarget( false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function restoreLinkPopups() {
|
|
|
|
|
global $wgExternalLinkTarget;
|
|
|
|
|
$this->parserOptions->setExternalLinkTarget( $wgExternalLinkTarget );
|
2010-12-16 11:20:39 +00:00
|
|
|
}
|
2010-12-10 03:02:03 +00:00
|
|
|
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
/**
|
2011-01-25 18:24:16 +00:00
|
|
|
* Install step which adds a row to the site_stats table with appropriate
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
* initial values.
|
|
|
|
|
*/
|
|
|
|
|
public function populateSiteStats( DatabaseInstaller $installer ) {
|
|
|
|
|
$status = $installer->getConnection();
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
2011-03-04 13:17:13 +00:00
|
|
|
$status->value->insert( 'site_stats', array(
|
|
|
|
|
'ss_row_id' => 1,
|
|
|
|
|
'ss_total_views' => 0,
|
|
|
|
|
'ss_total_edits' => 0,
|
|
|
|
|
'ss_good_articles' => 0,
|
|
|
|
|
'ss_total_pages' => 0,
|
|
|
|
|
'ss_users' => 0,
|
|
|
|
|
'ss_admins' => 0,
|
|
|
|
|
'ss_images' => 0 ),
|
|
|
|
|
__METHOD__, 'IGNORE' );
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
return Status::newGood();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
/**
|
|
|
|
|
* Exports all wg* variables stored by the installer into global scope.
|
|
|
|
|
*/
|
|
|
|
|
public function exportVars() {
|
|
|
|
|
foreach ( $this->settings as $name => $value ) {
|
|
|
|
|
if ( substr( $name, 0, 2 ) == 'wg' ) {
|
|
|
|
|
$GLOBALS[$name] = $value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for DB types.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckDB() {
|
2010-07-21 17:20:50 +00:00
|
|
|
global $wgLang;
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$compiledDBs = array();
|
|
|
|
|
$allNames = array();
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-08-15 18:55:08 +00:00
|
|
|
foreach ( self::getDBTypes() as $name ) {
|
2011-03-29 17:34:00 +00:00
|
|
|
if ( $this->getDBInstaller( $name )->isCompiled() ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$compiledDBs[] = $name;
|
|
|
|
|
}
|
2011-03-29 17:34:00 +00:00
|
|
|
$allNames[] = wfMsg( 'config-type-' . $name );;
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->setVar( '_CompiledDBs', $compiledDBs );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !$compiledDBs ) {
|
|
|
|
|
$this->showMessage( 'config-no-db' );
|
2010-08-15 16:42:43 +00:00
|
|
|
// FIXME: this only works for the web installer!
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->showHelpBox( 'config-no-db-help', $wgLang->commaList( $allNames ) );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-10-01 21:06:32 +00:00
|
|
|
// Check for FTS3 full-text search module
|
2010-10-15 14:11:59 +00:00
|
|
|
$sqlite = $this->getDBInstaller( 'sqlite' );
|
2010-10-01 21:06:32 +00:00
|
|
|
if ( $sqlite->isCompiled() ) {
|
|
|
|
|
$db = new DatabaseSqliteStandalone( ':memory:' );
|
2010-12-07 20:03:54 +00:00
|
|
|
if( $db->getFulltextSearchModule() != 'FTS3' ) {
|
2010-12-07 18:29:04 +00:00
|
|
|
$this->showMessage( 'config-no-fts3' );
|
|
|
|
|
}
|
2010-10-01 21:06:32 +00:00
|
|
|
}
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for register_globals.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckRegisterGlobals() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if( wfIniGetBool( "magic_quotes_runtime" ) ) {
|
|
|
|
|
$this->showMessage( 'config-register-globals' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-06 22:16:19 +00:00
|
|
|
/**
|
|
|
|
|
* Some versions of libxml+PHP break < and > encoding horribly
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckBrokenXML() {
|
2010-11-06 22:16:19 +00:00
|
|
|
$test = new PhpXmlBugTester();
|
|
|
|
|
if ( !$test->ok ) {
|
|
|
|
|
$this->showMessage( 'config-brokenlibxml' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test PHP (probably 5.3.1, but it could regress again) to make sure that
|
|
|
|
|
* reference parameters to __call() are not converted to null
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckPHP531() {
|
2010-11-06 22:16:19 +00:00
|
|
|
$test = new PhpRefCallBugTester;
|
|
|
|
|
$test->execute();
|
|
|
|
|
if ( !$test->ok ) {
|
2011-03-06 18:12:30 +00:00
|
|
|
$this->showMessage( 'config-using531', phpversion() );
|
2010-11-06 22:16:19 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for magic_quotes_runtime.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckMagicQuotes() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if( wfIniGetBool( "magic_quotes_runtime" ) ) {
|
|
|
|
|
$this->showMessage( 'config-magic-quotes-runtime' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for magic_quotes_sybase.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckMagicSybase() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
|
|
|
|
|
$this->showMessage( 'config-magic-quotes-sybase' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for mbstring.func_overload.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckMbstring() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( wfIniGetBool( 'mbstring.func_overload' ) ) {
|
|
|
|
|
$this->showMessage( 'config-mbstring' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for zend.ze1_compatibility_mode.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckZE1() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) {
|
|
|
|
|
$this->showMessage( 'config-ze1' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for safe_mode.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckSafeMode() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( wfIniGetBool( 'safe_mode' ) ) {
|
|
|
|
|
$this->setVar( '_SafeMode', true );
|
|
|
|
|
$this->showMessage( 'config-safe-mode' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for the XML module.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckXML() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !function_exists( "utf8_encode" ) ) {
|
|
|
|
|
$this->showMessage( 'config-xml-bad' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for the PCRE module.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckPCRE() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !function_exists( 'preg_match' ) ) {
|
|
|
|
|
$this->showMessage( 'config-pcre' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-11-10 16:45:28 +00:00
|
|
|
wfSuppressWarnings();
|
2011-02-19 07:27:27 +00:00
|
|
|
$regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' );
|
2010-11-10 16:45:28 +00:00
|
|
|
wfRestoreWarnings();
|
|
|
|
|
if ( $regexd != '--' ) {
|
|
|
|
|
$this->showMessage( 'config-pcre-no-utf8' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for available memory.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckMemory() {
|
2010-05-07 12:25:01 +00:00
|
|
|
$limit = ini_get( 'memory_limit' );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !$limit || $limit == -1 ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2011-01-25 22:42:53 +00:00
|
|
|
$n = wfShorthandToInteger( $limit );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
if( $n < $this->minMemorySize * 1024 * 1024 ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$newLimit = "{$this->minMemorySize}M";
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
if( ini_set( "memory_limit", $newLimit ) === false ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->showMessage( 'config-memory-bad', $limit );
|
|
|
|
|
} else {
|
|
|
|
|
$this->showMessage( 'config-memory-raised', $limit, $newLimit );
|
|
|
|
|
$this->setVar( '_RaiseMemory', true );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2010-12-07 18:29:04 +00:00
|
|
|
return true;
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for compiled object cache types.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckCache() {
|
2010-12-07 21:08:24 +00:00
|
|
|
$caches = array();
|
2010-05-07 12:25:01 +00:00
|
|
|
foreach ( $this->objectCaches as $name => $function ) {
|
|
|
|
|
if ( function_exists( $function ) ) {
|
|
|
|
|
$caches[$name] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !$caches ) {
|
|
|
|
|
$this->showMessage( 'config-no-cache' );
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->setVar( '_Caches', $caches );
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Search for GNU diff3.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckDiff3() {
|
2010-05-07 12:25:01 +00:00
|
|
|
$names = array( "gdiff3", "diff3", "diff3.exe" );
|
2010-11-08 14:16:22 +00:00
|
|
|
$versionInfo = array( '$1 --version 2>&1', 'GNU diffutils' );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-12-13 13:13:29 +00:00
|
|
|
$diff3 = self::locateExecutableInDefaultPaths( $names, $versionInfo );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-10-17 17:20:12 +00:00
|
|
|
if ( $diff3 ) {
|
|
|
|
|
$this->setVar( 'wgDiff3', $diff3 );
|
2010-05-07 12:25:01 +00:00
|
|
|
} else {
|
|
|
|
|
$this->setVar( 'wgDiff3', false );
|
|
|
|
|
$this->showMessage( 'config-diff3-bad' );
|
2010-07-22 17:58:26 +00:00
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:20:50 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for ImageMagick and GD.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckGraphics() {
|
2010-10-18 16:21:31 +00:00
|
|
|
$names = array( wfIsWindows() ? 'convert.exe' : 'convert' );
|
2010-12-13 13:13:29 +00:00
|
|
|
$convert = self::locateExecutableInDefaultPaths( $names, array( '$1 -version', 'ImageMagick' ) );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2011-03-07 18:45:43 +00:00
|
|
|
$this->setVar( 'wgImageMagickConvertCommand', '' );
|
2010-10-17 17:20:12 +00:00
|
|
|
if ( $convert ) {
|
|
|
|
|
$this->setVar( 'wgImageMagickConvertCommand', $convert );
|
|
|
|
|
$this->showMessage( 'config-imagemagick', $convert );
|
2010-10-16 18:19:00 +00:00
|
|
|
return true;
|
|
|
|
|
} elseif ( function_exists( 'imagejpeg' ) ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->showMessage( 'config-gd' );
|
|
|
|
|
return true;
|
2010-10-16 18:19:00 +00:00
|
|
|
} else {
|
|
|
|
|
$this->showMessage( 'no-scaling' );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:31:00 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for setting $IP and $wgScriptPath.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckPath() {
|
2010-07-25 18:04:41 +00:00
|
|
|
global $IP;
|
2010-05-07 12:25:01 +00:00
|
|
|
$IP = dirname( dirname( dirname( __FILE__ ) ) );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->setVar( 'IP', $IP );
|
|
|
|
|
|
|
|
|
|
// 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'] ) ) {
|
|
|
|
|
$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->showMessage( 'config-no-uri' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2011-02-26 12:51:35 +00:00
|
|
|
$uri = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->setVar( 'wgScriptPath', $uri );
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:31:00 +00:00
|
|
|
/**
|
|
|
|
|
* Environment check for setting the preferred PHP file extension.
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckExtension() {
|
2010-05-07 12:25:01 +00:00
|
|
|
// FIXME: detect this properly
|
|
|
|
|
if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
|
|
|
|
|
$ext = 'php5';
|
|
|
|
|
} else {
|
|
|
|
|
$ext = 'php';
|
|
|
|
|
}
|
|
|
|
|
$this->setVar( 'wgScriptExtension', ".$ext" );
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
/**
|
|
|
|
|
* TODO: document
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckShellLocale() {
|
2010-05-07 12:25:01 +00:00
|
|
|
$os = php_uname( 's' );
|
2010-10-17 20:34:25 +00:00
|
|
|
$supported = array( 'Linux', 'SunOS', 'HP-UX', 'Darwin' ); # Tested these
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !in_array( $os, $supported ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:31:00 +00:00
|
|
|
# Get a list of available locales.
|
2010-10-31 23:19:40 +00:00
|
|
|
$ret = false;
|
2010-10-17 20:36:07 +00:00
|
|
|
$lines = wfShellExec( '/usr/bin/locale -a', $ret );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $ret ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-17 20:34:25 +00:00
|
|
|
$lines = wfArrayMap( 'trim', explode( "\n", $lines ) );
|
2010-05-07 12:25:01 +00:00
|
|
|
$candidatesByLocale = array();
|
|
|
|
|
$candidatesByLang = array();
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
foreach ( $lines as $line ) {
|
|
|
|
|
if ( $line === '' ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
list( $all, $lang, $territory, $charset, $modifier ) = $m;
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$candidatesByLocale[$m[0]] = $m;
|
|
|
|
|
$candidatesByLang[$lang][] = $m;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:31:00 +00:00
|
|
|
# Try the current value of LANG.
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
|
|
|
|
|
$this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:31:00 +00:00
|
|
|
# Try the most common ones.
|
2010-05-07 12:25:01 +00:00
|
|
|
$commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
|
|
|
|
|
foreach ( $commonLocales as $commonLocale ) {
|
|
|
|
|
if ( isset( $candidatesByLocale[$commonLocale] ) ) {
|
|
|
|
|
$this->setVar( 'wgShellLocale', $commonLocale );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Is there an available locale in the Wiki's language?
|
|
|
|
|
$wikiLang = $this->getVar( 'wgLanguageCode' );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( isset( $candidatesByLang[$wikiLang] ) ) {
|
|
|
|
|
$m = reset( $candidatesByLang[$wikiLang] );
|
|
|
|
|
$this->setVar( 'wgShellLocale', $m[0] );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Are there any at all?
|
|
|
|
|
if ( count( $candidatesByLocale ) ) {
|
|
|
|
|
$m = reset( $candidatesByLocale );
|
|
|
|
|
$this->setVar( 'wgShellLocale', $m[0] );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 17:31:00 +00:00
|
|
|
# Give up.
|
2010-05-07 12:25:01 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2010-07-18 18:52:05 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
/**
|
|
|
|
|
* TODO: document
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckUploadsDirectory() {
|
2010-05-07 12:25:01 +00:00
|
|
|
global $IP, $wgServer;
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$dir = $IP . '/images/';
|
|
|
|
|
$url = $wgServer . $this->getVar( 'wgScriptPath' ) . '/images/';
|
|
|
|
|
$safe = !$this->dirIsExecutable( $dir, $url );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $safe ) {
|
2010-12-07 18:29:04 +00:00
|
|
|
return true;
|
2010-05-07 12:25:01 +00:00
|
|
|
} else {
|
|
|
|
|
$this->showMessage( 'config-uploads-not-safe', $dir );
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-29 02:44:23 +00:00
|
|
|
/**
|
|
|
|
|
* Convert a hex string representing a Unicode code point to that code point.
|
2010-08-21 18:20:09 +00:00
|
|
|
* @param $c String
|
2010-07-29 02:44:23 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
protected function unicodeChar( $c ) {
|
|
|
|
|
$c = hexdec($c);
|
|
|
|
|
if ($c <= 0x7F) {
|
|
|
|
|
return chr($c);
|
|
|
|
|
} else if ($c <= 0x7FF) {
|
|
|
|
|
return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
|
|
|
|
|
} else if ($c <= 0xFFFF) {
|
|
|
|
|
return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
|
|
|
|
|
. chr(0x80 | $c & 0x3F);
|
|
|
|
|
} else if ($c <= 0x10FFFF) {
|
|
|
|
|
return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
|
|
|
|
|
. chr(0x80 | $c >> 6 & 0x3F)
|
|
|
|
|
. chr(0x80 | $c & 0x3F);
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check the libicu version
|
|
|
|
|
*/
|
2010-11-16 15:50:32 +00:00
|
|
|
protected function envCheckLibicu() {
|
2010-07-29 02:44:23 +00:00
|
|
|
$utf8 = function_exists( 'utf8_normalize' );
|
|
|
|
|
$intl = function_exists( 'normalizer_normalize' );
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This needs to be updated something that the latest libicu
|
|
|
|
|
* will properly normalize. This normalization was found at
|
|
|
|
|
* http://www.unicode.org/versions/Unicode5.2.0/#Character_Additions
|
|
|
|
|
* Note that we use the hex representation to create the code
|
2010-07-29 19:28:16 +00:00
|
|
|
* points in order to avoid any Unicode-destroying during transit.
|
2010-07-29 02:44:23 +00:00
|
|
|
*/
|
|
|
|
|
$not_normal_c = $this->unicodeChar("FA6C");
|
|
|
|
|
$normal_c = $this->unicodeChar("242EE");
|
|
|
|
|
|
2010-08-02 11:54:11 +00:00
|
|
|
$useNormalizer = 'php';
|
2010-07-29 19:28:16 +00:00
|
|
|
$needsUpdate = false;
|
2010-07-29 02:44:23 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* We're going to prefer the pecl extension here unless
|
|
|
|
|
* utf8_normalize is more up to date.
|
|
|
|
|
*/
|
|
|
|
|
if( $utf8 ) {
|
2010-08-02 11:54:11 +00:00
|
|
|
$useNormalizer = 'utf8';
|
2010-07-29 19:28:16 +00:00
|
|
|
$utf8 = utf8_normalize( $not_normal_c, UNORM_NFC );
|
|
|
|
|
if ( $utf8 !== $normal_c ) $needsUpdate = true;
|
2010-07-29 02:44:23 +00:00
|
|
|
}
|
|
|
|
|
if( $intl ) {
|
2010-08-02 11:54:11 +00:00
|
|
|
$useNormalizer = 'intl';
|
2010-07-29 19:28:16 +00:00
|
|
|
$intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C );
|
|
|
|
|
if ( $intl !== $normal_c ) $needsUpdate = true;
|
2010-07-29 02:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-02 11:54:11 +00:00
|
|
|
// Uses messages 'config-unicode-using-php', 'config-unicode-using-utf8', 'config-unicode-using-intl'
|
|
|
|
|
if( $useNormalizer === 'php' ) {
|
2010-07-29 02:44:23 +00:00
|
|
|
$this->showMessage( 'config-unicode-pure-php-warning' );
|
2010-11-03 11:53:46 +00:00
|
|
|
} else {
|
|
|
|
|
$this->showMessage( 'config-unicode-using-' . $useNormalizer );
|
|
|
|
|
if( $needsUpdate ) {
|
|
|
|
|
$this->showMessage( 'config-unicode-update-warning' );
|
|
|
|
|
}
|
2010-07-29 02:44:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-17 17:20:12 +00:00
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
* (which should maybe make it work for Windows?)
|
|
|
|
|
*
|
|
|
|
|
* @return Array
|
|
|
|
|
*/
|
2010-11-06 22:16:19 +00:00
|
|
|
protected static function getPossibleBinPaths() {
|
2010-10-17 17:20:12 +00:00
|
|
|
return array_merge(
|
|
|
|
|
array( '/usr/bin', '/usr/local/bin', '/opt/csw/bin',
|
|
|
|
|
'/usr/gnu/bin', '/usr/sfw/bin', '/sw/bin', '/opt/local/bin' ),
|
|
|
|
|
explode( PATH_SEPARATOR, getenv( 'PATH' ) )
|
|
|
|
|
);
|
|
|
|
|
}
|
2010-07-29 02:44:23 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
/**
|
|
|
|
|
* 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.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* Used only by environment checks.
|
|
|
|
|
*
|
|
|
|
|
* @param $path String: path to search
|
|
|
|
|
* @param $names Array of executable names
|
|
|
|
|
* @param $versionInfo Boolean false or array with two members:
|
2010-11-11 23:04:55 +00:00
|
|
|
* 0 => Command to run for version check, with $1 for the full executable name
|
2010-07-22 17:58:26 +00:00
|
|
|
* 1 => String to compare the output with
|
|
|
|
|
*
|
|
|
|
|
* If $versionInfo is not false, only executables with a version
|
|
|
|
|
* matching $versionInfo[1] will be returned.
|
|
|
|
|
*/
|
2010-11-06 22:16:19 +00:00
|
|
|
public static function locateExecutable( $path, $names, $versionInfo = false ) {
|
2010-07-22 17:58:26 +00:00
|
|
|
if ( !is_array( $names ) ) {
|
|
|
|
|
$names = array( $names );
|
|
|
|
|
}
|
2010-05-07 12:25:01 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
foreach ( $names as $name ) {
|
2010-10-18 16:21:31 +00:00
|
|
|
$command = $path . DIRECTORY_SEPARATOR . $name;
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
wfSuppressWarnings();
|
|
|
|
|
$file_exists = file_exists( $command );
|
|
|
|
|
wfRestoreWarnings();
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
if ( $file_exists ) {
|
|
|
|
|
if ( !$versionInfo ) {
|
|
|
|
|
return $command;
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-11-12 18:47:33 +00:00
|
|
|
$file = str_replace( '$1', wfEscapeShellArg( $command ), $versionInfo[0] );
|
2010-11-08 14:16:22 +00:00
|
|
|
if ( strstr( wfShellExec( $file ), $versionInfo[1] ) !== false ) {
|
2010-07-22 17:58:26 +00:00
|
|
|
return $command;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-10-17 17:20:12 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-10-17 17:20:12 +00:00
|
|
|
/**
|
|
|
|
|
* Same as locateExecutable(), but checks in getPossibleBinPaths() by default
|
|
|
|
|
* @see locateExecutable()
|
|
|
|
|
*/
|
2010-11-06 22:16:19 +00:00
|
|
|
public static function locateExecutableInDefaultPaths( $names, $versionInfo = false ) {
|
|
|
|
|
foreach( self::getPossibleBinPaths() as $path ) {
|
|
|
|
|
$exe = self::locateExecutable( $path, $names, $versionInfo );
|
2010-10-17 17:20:12 +00:00
|
|
|
if( $exe !== false ) {
|
|
|
|
|
return $exe;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-22 17:58:26 +00:00
|
|
|
return false;
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-19 02:41:54 +00:00
|
|
|
* Checks if scripts located in the given directory can be executed via the given URL.
|
2010-07-29 18:18:03 +00:00
|
|
|
*
|
2010-07-22 17:58:26 +00:00
|
|
|
* Used only by environment checks.
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 02:41:54 +00:00
|
|
|
public function dirIsExecutable( $dir, $url ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$scriptTypes = array(
|
|
|
|
|
'php' => array(
|
|
|
|
|
"<?php echo 'ex' . 'ec';",
|
|
|
|
|
"#!/var/env php5\n<?php echo 'ex' . 'ec';",
|
|
|
|
|
),
|
|
|
|
|
);
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-07-21 17:31:00 +00:00
|
|
|
// it would be good to check other popular languages here, but it'll be slow.
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
wfSuppressWarnings();
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
foreach ( $scriptTypes as $ext => $contents ) {
|
|
|
|
|
foreach ( $contents as $source ) {
|
|
|
|
|
$file = 'exectest.' . $ext;
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !file_put_contents( $dir . $file, $source ) ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
$text = Http::get( $url . $file, array( 'timeout' => 3 ) );
|
2010-05-07 12:25:01 +00:00
|
|
|
unlink( $dir . $file );
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $text == 'exec' ) {
|
|
|
|
|
wfRestoreWarnings();
|
|
|
|
|
return $ext;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
wfRestoreWarnings();
|
2010-07-29 18:18:03 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return false;
|
2010-07-29 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-21 15:27:16 +00:00
|
|
|
/**
|
|
|
|
|
* ParserOptions are constructed before we determined the language, so fix it
|
|
|
|
|
*/
|
|
|
|
|
public function setParserLanguage( $lang ) {
|
|
|
|
|
$this->parserOptions->setTargetLanguage( $lang );
|
|
|
|
|
$this->parserOptions->setUserLang( $lang->getCode() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Overridden by WebInstaller to provide lastPage parameters.
|
|
|
|
|
*/
|
|
|
|
|
protected function getDocUrl( $page ) {
|
|
|
|
|
return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Finds extensions that follow the format /extensions/Name/Name.php,
|
|
|
|
|
* and returns an array containing the value for 'Name' for each found extension.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function findExtensions() {
|
|
|
|
|
if( $this->getVar( 'IP' ) === null ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$exts = array();
|
|
|
|
|
$dir = $this->getVar( 'IP' ) . '/extensions';
|
|
|
|
|
$dh = opendir( $dir );
|
|
|
|
|
|
|
|
|
|
while ( ( $file = readdir( $dh ) ) !== false ) {
|
|
|
|
|
if( file_exists( "$dir/$file/$file.php" ) ) {
|
|
|
|
|
$exts[] = $file;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $exts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Installs the auto-detected extensions.
|
|
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
protected function includeExtensions() {
|
2011-01-31 20:00:59 +00:00
|
|
|
global $IP;
|
2011-01-21 15:27:16 +00:00
|
|
|
$exts = $this->getVar( '_Extensions' );
|
2011-01-31 20:00:59 +00:00
|
|
|
$IP = $this->getVar( 'IP' );
|
|
|
|
|
$path = $IP . '/extensions';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* We need to include DefaultSettings before including extensions to avoid
|
|
|
|
|
* warnings about unset variables. However, the only thing we really
|
|
|
|
|
* want here is $wgHooks['LoadExtensionSchemaUpdates']. This won't work
|
|
|
|
|
* if the extension has hidden hook registration in $wgExtensionFunctions,
|
|
|
|
|
* but we're not opening that can of worms
|
|
|
|
|
* @see https://bugzilla.wikimedia.org/show_bug.cgi?id=26857
|
|
|
|
|
*/
|
2011-03-25 18:24:58 +00:00
|
|
|
global $wgAutoloadClasses;
|
2011-01-31 20:00:59 +00:00
|
|
|
require( "$IP/includes/DefaultSettings.php" );
|
2011-01-21 15:27:16 +00:00
|
|
|
|
|
|
|
|
foreach( $exts as $e ) {
|
2011-03-20 18:47:16 +00:00
|
|
|
require_once( "$path/$e/$e.php" );
|
2011-01-21 15:27:16 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-01 17:54:15 +00:00
|
|
|
$hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
|
|
|
|
|
$wgHooks['LoadExtensionSchemaUpdates'] : array();
|
|
|
|
|
|
|
|
|
|
// Unset everyone else's hooks. Lord knows what someone might be doing
|
|
|
|
|
// in ParserFirstCallInit (see bug 27171)
|
2011-03-25 18:24:58 +00:00
|
|
|
$GLOBALS['wgHooks'] = array( 'LoadExtensionSchemaUpdates' => $hooksWeWant );
|
2011-03-01 17:54:15 +00:00
|
|
|
|
2011-01-21 15:27:16 +00:00
|
|
|
return Status::newGood();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get an array of install steps. Should always be in the format of
|
|
|
|
|
* array(
|
|
|
|
|
* 'name' => 'someuniquename',
|
|
|
|
|
* 'callback' => array( $obj, 'method' ),
|
|
|
|
|
* )
|
|
|
|
|
* There must be a config-install-$name message defined per step, which will
|
|
|
|
|
* be shown on install.
|
|
|
|
|
*
|
|
|
|
|
* @param $installer DatabaseInstaller so we can make callbacks
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
protected function getInstallSteps( DatabaseInstaller $installer ) {
|
2011-01-21 15:27:16 +00:00
|
|
|
$coreInstallSteps = array(
|
|
|
|
|
array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ),
|
2011-01-24 18:36:09 +00:00
|
|
|
array( 'name' => 'tables', 'callback' => array( $installer, 'createTables' ) ),
|
2011-01-21 15:27:16 +00:00
|
|
|
array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
array( 'name' => 'stats', 'callback' => array( $this, 'populateSiteStats' ) ),
|
2011-01-21 15:27:16 +00:00
|
|
|
array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ),
|
|
|
|
|
array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ),
|
|
|
|
|
array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
|
|
|
|
|
array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 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 ) {
|
|
|
|
|
$this->installSteps[] = $step;
|
|
|
|
|
if( isset( $this->extraInstallSteps[ $step['name'] ] ) ) {
|
|
|
|
|
$this->installSteps = array_merge(
|
|
|
|
|
$this->installSteps,
|
|
|
|
|
$this->extraInstallSteps[ $step['name'] ]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Prepend any steps that want to be at the beginning
|
|
|
|
|
if( isset( $this->extraInstallSteps['BEGINNING'] ) ) {
|
|
|
|
|
$this->installSteps = array_merge(
|
|
|
|
|
$this->extraInstallSteps['BEGINNING'],
|
|
|
|
|
$this->installSteps
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Extensions should always go first, chance to tie into hooks and such
|
|
|
|
|
if( count( $this->getVar( '_Extensions' ) ) ) {
|
|
|
|
|
array_unshift( $this->installSteps,
|
|
|
|
|
array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) )
|
|
|
|
|
);
|
2011-01-31 20:00:59 +00:00
|
|
|
$this->installSteps[] = array(
|
|
|
|
|
'name' => 'extension-tables',
|
|
|
|
|
'callback' => array( $installer, 'createExtensionTables' )
|
|
|
|
|
);
|
2011-01-21 15:27:16 +00:00
|
|
|
}
|
|
|
|
|
return $this->installSteps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Actually perform the installation.
|
|
|
|
|
*
|
2011-02-19 00:44:38 +00:00
|
|
|
* @param $startCB Array A callback array for the beginning of each step
|
|
|
|
|
* @param $endCB Array A callback array for the end of each step
|
2011-01-21 15:27:16 +00:00
|
|
|
*
|
|
|
|
|
* @return Array of Status objects
|
|
|
|
|
*/
|
|
|
|
|
public function performInstallation( $startCB, $endCB ) {
|
|
|
|
|
$installResults = array();
|
|
|
|
|
$installer = $this->getDBInstaller();
|
|
|
|
|
$installer->preInstall();
|
|
|
|
|
$steps = $this->getInstallSteps( $installer );
|
|
|
|
|
foreach( $steps as $stepObj ) {
|
|
|
|
|
$name = $stepObj['name'];
|
|
|
|
|
call_user_func_array( $startCB, array( $name ) );
|
|
|
|
|
|
|
|
|
|
// Perform the callback step
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
$status = call_user_func( $stepObj['callback'], $installer );
|
2011-01-21 15:27:16 +00:00
|
|
|
|
|
|
|
|
// Output and save the results
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
call_user_func( $endCB, $name, $status );
|
2011-01-21 15:27:16 +00:00
|
|
|
$installResults[$name] = $status;
|
|
|
|
|
|
|
|
|
|
// If we've hit some sort of fatal, we need to bail.
|
|
|
|
|
// Callback already had a chance to do output above.
|
|
|
|
|
if( !$status->isOk() ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if( $status->isOk() ) {
|
|
|
|
|
$this->setVar( '_InstallDone', true );
|
|
|
|
|
}
|
|
|
|
|
return $installResults;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate $wgSecretKey. Will warn if we had to use mt_rand() instead of
|
|
|
|
|
* /dev/urandom
|
|
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
2011-03-29 17:06:26 +00:00
|
|
|
public function generateSecretKey() {
|
2011-01-21 15:27:16 +00:00
|
|
|
return $this->generateSecret( 'wgSecretKey' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a secret value for a variable using either
|
|
|
|
|
* /dev/urandom or mt_rand() Produce a warning in the later case.
|
|
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
protected function generateSecret( $secretName, $length = 64 ) {
|
|
|
|
|
if ( wfIsWindows() ) {
|
|
|
|
|
$file = null;
|
|
|
|
|
} else {
|
|
|
|
|
wfSuppressWarnings();
|
|
|
|
|
$file = fopen( "/dev/urandom", "r" );
|
|
|
|
|
wfRestoreWarnings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$status = Status::newGood();
|
|
|
|
|
|
|
|
|
|
if ( $file ) {
|
|
|
|
|
$secretKey = bin2hex( fread( $file, $length / 2 ) );
|
|
|
|
|
fclose( $file );
|
|
|
|
|
} else {
|
|
|
|
|
$secretKey = '';
|
|
|
|
|
|
|
|
|
|
for ( $i = 0; $i < $length / 8; $i++ ) {
|
|
|
|
|
$secretKey .= dechex( mt_rand( 0, 0x7fffffff ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$status->warning( 'config-insecure-secret', '$' . $secretName );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->setVar( $secretName, $secretKey );
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
}
|
2011-01-25 23:37:11 +00:00
|
|
|
return Status::newGood();
|
2011-01-21 15:27:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create the first user account, grant it sysop and bureaucrat rights
|
|
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
protected function createSysop() {
|
|
|
|
|
$name = $this->getVar( '_AdminName' );
|
|
|
|
|
$user = User::newFromName( $name );
|
|
|
|
|
|
|
|
|
|
if ( !$user ) {
|
|
|
|
|
// We should've validated this earlier anyway!
|
|
|
|
|
return Status::newFatal( 'config-admin-error-user', $name );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $user->idForName() == 0 ) {
|
|
|
|
|
$user->addToDatabase();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$user->setPassword( $this->getVar( '_AdminPassword' ) );
|
|
|
|
|
} catch( PasswordError $pwe ) {
|
|
|
|
|
return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$user->addGroup( 'sysop' );
|
|
|
|
|
$user->addGroup( 'bureaucrat' );
|
|
|
|
|
if( $this->getVar( '_AdminEmail' ) ) {
|
|
|
|
|
$user->setEmail( $this->getVar( '_AdminEmail' ) );
|
|
|
|
|
}
|
|
|
|
|
$user->saveSettings();
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
|
|
|
|
|
// Update user count
|
|
|
|
|
$ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
|
|
|
|
|
$ssUpdate->doUpdate();
|
2011-01-21 15:27:16 +00:00
|
|
|
}
|
|
|
|
|
$status = Status::newGood();
|
|
|
|
|
|
|
|
|
|
if( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
|
|
|
|
|
$this->subscribeToMediaWikiAnnounce( $status );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function subscribeToMediaWikiAnnounce( Status $s ) {
|
|
|
|
|
$params = array(
|
|
|
|
|
'email' => $this->getVar( '_AdminEmail' ),
|
|
|
|
|
'language' => 'en',
|
|
|
|
|
'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 ) ) {
|
|
|
|
|
$myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR
|
|
|
|
|
$params['language'] = $myLang;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$res = Http::post( $this->mediaWikiAnnounceUrl, array( 'postData' => $params ) );
|
|
|
|
|
if( !$res ) {
|
|
|
|
|
$s->warning( 'config-install-subscribe-fail' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Insert Main Page with default content.
|
|
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
protected function createMainpage( DatabaseInstaller $installer ) {
|
2011-01-21 15:27:16 +00:00
|
|
|
$status = Status::newGood();
|
|
|
|
|
try {
|
2011-01-26 00:23:39 +00:00
|
|
|
$article = new Article( Title::newMainPage() );
|
2011-01-21 15:27:16 +00:00
|
|
|
$article->doEdit( wfMsgForContent( 'mainpagetext' ) . "\n\n" .
|
|
|
|
|
wfMsgForContent( 'mainpagedocfooter' ),
|
|
|
|
|
'',
|
|
|
|
|
EDIT_NEW,
|
|
|
|
|
false,
|
2011-01-24 20:54:13 +00:00
|
|
|
User::newFromName( 'MediaWiki default' ) );
|
2011-01-21 15:27:16 +00:00
|
|
|
} catch (MWException $e) {
|
|
|
|
|
//using raw, because $wgShowExceptionDetails can not be set yet
|
|
|
|
|
$status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Override the necessary bits of the config to run an installation.
|
|
|
|
|
*/
|
|
|
|
|
public static function overrideConfig() {
|
|
|
|
|
define( 'MW_NO_SESSION', 1 );
|
|
|
|
|
|
|
|
|
|
// Don't access the database
|
|
|
|
|
$GLOBALS['wgUseDatabaseMessages'] = false;
|
|
|
|
|
// Debug-friendly
|
|
|
|
|
$GLOBALS['wgShowExceptionDetails'] = true;
|
|
|
|
|
// Don't break forms
|
|
|
|
|
$GLOBALS['wgExternalLinkTarget'] = '_blank';
|
|
|
|
|
|
|
|
|
|
// Extended debugging
|
|
|
|
|
$GLOBALS['wgShowSQLErrors'] = true;
|
|
|
|
|
$GLOBALS['wgShowDBErrorBacktrace'] = true;
|
|
|
|
|
|
|
|
|
|
// Allow multiple ob_flush() calls
|
|
|
|
|
$GLOBALS['wgDisableOutputCompression'] = true;
|
|
|
|
|
|
|
|
|
|
// Use a sensible cookie prefix (not my_wiki)
|
|
|
|
|
$GLOBALS['wgCookiePrefix'] = 'mw_installer';
|
|
|
|
|
|
|
|
|
|
// Some of the environment checks make shell requests, remove limits
|
|
|
|
|
$GLOBALS['wgMaxShellMemory'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add an installation step following the given step.
|
|
|
|
|
*
|
|
|
|
|
* @param $callback Array A valid installation callback array, in this form:
|
|
|
|
|
* array( 'name' => 'some-unique-name', 'callback' => array( $obj, 'function' ) );
|
|
|
|
|
* @param $findStep String the step to find. Omit to put the step at the beginning
|
|
|
|
|
*/
|
|
|
|
|
public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
|
|
|
|
|
$this->extraInstallSteps[$findStep][] = $callback;
|
|
|
|
|
}
|
2010-07-25 18:04:41 +00:00
|
|
|
}
|