}
/**
- * Create database tables from scratch.
+ * Apply a SQL source file to the database as part of running an installation step.
*
+ * @param string $sourceFileMethod
+ * @param string $stepName
+ * @param string $archiveTableMustNotExist
* @return Status
*/
- public function createTables() {
+ private function stepApplySourceFile(
+ $sourceFileMethod,
+ $stepName,
+ $archiveTableMustNotExist = false
+ ) {
$status = $this->getConnection();
if ( !$status->isOK() ) {
return $status;
}
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
- if ( $this->db->tableExists( 'archive', __METHOD__ ) ) {
- $status->warning( 'config-install-tables-exist' );
+ if ( $archiveTableMustNotExist && $this->db->tableExists( 'archive', __METHOD__ ) ) {
+ $status->warning( "config-$stepName-tables-exist" );
$this->enableLB();
return $status;
$this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files
$this->db->begin( __METHOD__ );
- $error = $this->db->sourceFile( $this->db->getSchemaPath() );
+ $error = $this->db->sourceFile(
+ call_user_func( array( $this->db, $sourceFileMethod ) )
+ );
if ( $error !== true ) {
$this->db->reportQueryError( $error, 0, '', __METHOD__ );
$this->db->rollback( __METHOD__ );
- $status->fatal( 'config-install-tables-failed', $error );
+ $status->fatal( "config-$stepName-tables-failed", $error );
} else {
$this->db->commit( __METHOD__ );
}
return $status;
}
+ /**
+ * Create database tables from scratch.
+ *
+ * @return Status
+ */
+ public function createTables() {
+ return $this->stepApplySourceFile( 'getSchemaPath', 'install', true );
+ }
+
+ /**
+ * Insert update keys into table to prevent running unneded updates.
+ *
+ * @return Status
+ */
+ public function insertUpdateKeys() {
+ return $this->stepApplySourceFile( 'getUpdateKeysPath', 'updates', false );
+ }
+
/**
* Create the tables for each extension the user enabled
* @return Status
/**
* Get the DBMS-specific options for LocalSettings.php generation.
*
- * @return String
+ * @return string
*/
abstract public function getLocalSettings();
/**
* Perform database upgrades
*
- * @return Boolean
+ * @return bool
*/
public function doUpgrade() {
$this->setupSchemaVars();
/**
* Construct and initialise parent.
* This is typically only called from Installer::getDBInstaller()
- * @param $parent
+ * @param WebInstaller $parent
*/
public function __construct( $parent ) {
$this->parent = $parent;
* Convenience function.
* Check if a named extension is present.
*
- * @param $name
+ * @param string $name
* @return bool
*/
protected static function checkExtension( $name ) {
/**
* Get the internationalised name for this DBMS.
- * @return String
+ * @return string
*/
public function getReadableName() {
// Messages: config-type-mysql, config-type-postgres, config-type-sqlite,
/**
* Get a variable, taking local defaults into account.
- * @param $var string
- * @param $default null
+ * @param string $var
+ * @param mixed|null $default
* @return mixed
*/
public function getVar( $var, $default = null ) {
/**
* Convenience alias for $this->parent->setVar()
- * @param $name string
- * @param $value mixed
+ * @param string $name
+ * @param mixed $value
*/
public function setVar( $name, $value ) {
$this->parent->setVar( $name, $value );
/**
* Get a labelled text box to configure a local variable.
*
- * @param $var string
- * @param $label string
- * @param $attribs array
- * @param $helpData string
+ * @param string $var
+ * @param string $label
+ * @param array $attribs
+ * @param string $helpData
* @return string
*/
public function getTextBox( $var, $label, $attribs = array(), $helpData = "" ) {
* Get a labelled password box to configure a local variable.
* Implements password hiding.
*
- * @param $var string
- * @param $label string
- * @param $attribs array
- * @param $helpData string
+ * @param string $var
+ * @param string $label
+ * @param array $attribs
+ * @param string $helpData
* @return string
*/
public function getPasswordBox( $var, $label, $attribs = array(), $helpData = "" ) {
/**
* Get a set of labelled radio buttons.
*
- * @param $params Array:
- * Parameters are:
+ * @param array $params Parameters are:
* var: The variable to be configured (required)
* label: The message name for the label (required)
* itemLabelPrefix: The message name prefix for the item labels (required)
* Convenience function to set variables based on form data.
* Assumes that variables containing "password" in the name are (potentially
* fake) passwords.
- * @param $varNames Array
+ * @param array $varNames
* @return array
*/
public function setVarsFromRequest( $varNames ) {
* Traditionally, this is done by testing for the existence of either
* the revision table or the cur table.
*
- * @return Boolean
+ * @return bool
*/
public function needsUpgrade() {
$status = $this->getConnection();
/**
* Get a standard install-user fieldset.
*
- * @return String
+ * @return string
*/
public function getInstallUserBox() {
return Html::openElement( 'fieldset' ) .
* @param string|bool $noCreateMsg Message to display instead of the creation checkbox.
* Set this to false to show a creation checkbox (default).
*
- * @return String
+ * @return string
*/
public function getWebUserBox( $noCreateMsg = false ) {
$wrapperStyle = $this->getVar( '_SameAccount' ) ? 'display: none' : '';