X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Finstaller%2FDatabaseInstaller.php;h=0beedfa462bf03856242525fab090197e259f60d;hb=4190fe5b697d927427d8026177d479f582e933aa;hp=d8e24421e225cf000ed2a4cda12a54c34f9a95d0;hpb=f2b428c31723189464bee5951e5f4afdf5344da6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index d8e24421e2..0beedfa462 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -2,6 +2,21 @@ /** * DBMS-specific installation helper. * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup Deployment */ @@ -50,10 +65,19 @@ abstract class DatabaseInstaller { public abstract function getName(); /** - * @return true if the client library is compiled in. + * @return bool Returns true if the client library is compiled in. */ public abstract function isCompiled(); + /** + * Checks for installation prerequisites other than those checked by isCompiled() + * @since 1.19 + * @return Status + */ + public function checkPrerequisites() { + return Status::newGood(); + } + /** * Get HTML for a web form that configures this database. Configuration * at this time should be the minimum needed to connect and test @@ -79,6 +103,7 @@ abstract class DatabaseInstaller { * $this->parent can be assumed to be a WebInstaller. * If the DB type has no settings beyond those already configured with * getConnectForm(), this should return false. + * @return bool */ public function getSettingsForm() { return false; @@ -102,7 +127,7 @@ abstract class DatabaseInstaller { * * @return Status */ - public abstract function openConnection( $dbName = null ); + public abstract function openConnection(); /** * Create the database and return a Status object indicating success or @@ -121,19 +146,17 @@ abstract class DatabaseInstaller { * * @return Status */ - public function getConnection( $dbName = null ) { - if ( isset($this->db) && $this->db ) { /* Weirdly get E_STRICT - * errors without the - * isset */ + public function getConnection() { + if ( $this->db ) { return Status::newGood( $this->db ); } - $status = $this->openConnection( $dbName ); + $status = $this->openConnection(); if ( $status->isOK() ) { $this->db = $status->value; // Enable autocommit $this->db->clearFlag( DBO_TRX ); - $this->db->commit(); + $this->db->commit( __METHOD__ ); } return $status; } @@ -150,7 +173,7 @@ abstract class DatabaseInstaller { } $this->db->selectDB( $this->getVar( 'wgDBname' ) ); - if( $this->db->tableExists( 'user' ) ) { + if( $this->db->tableExists( 'archive', __METHOD__ ) ) { $status->warning( 'config-install-tables-exist' ); $this->enableLB(); return $status; @@ -159,7 +182,7 @@ abstract class DatabaseInstaller { $this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files $this->db->begin( __METHOD__ ); - $error = $this->db->sourceFile( $this->db->getSchema() ); + $error = $this->db->sourceFile( $this->db->getSchemaPath() ); if( $error !== true ) { $this->db->reportQueryError( $error, 0, '', __METHOD__ ); $this->db->rollback( __METHOD__ ); @@ -183,26 +206,9 @@ abstract class DatabaseInstaller { if ( !$status->isOK() ) { return $status; } - $updater = DatabaseUpdater::newForDB( $this->db ); - $extensionUpdates = $updater->getNewExtensions(); - - $ourExtensions = array_map( 'strtolower', $this->getVar( '_Extensions' ) ); - - foreach( $ourExtensions as $ext ) { - if( isset( $extensionUpdates[$ext] ) ) { - $this->db->begin( __METHOD__ ); - $error = $this->db->sourceFile( $extensionUpdates[$ext] ); - if( $error !== true ) { - $this->db->rollback( __METHOD__ ); - $status->warning( 'config-install-tables-failed', $error ); - } else { - $this->db->commit( __METHOD__ ); - } - } - } // Now run updates to create tables for old extensions - $updater->doUpdates( array( 'extensions' ) ); + DatabaseUpdater::newForDB( $this->db )->doUpdates( array( 'extensions' ) ); return $status; } @@ -217,6 +223,7 @@ abstract class DatabaseInstaller { /** * Override this to provide DBMS-specific schema variables, to be * substituted into tables.sql and other schema files. + * @return array */ public function getSchemaVars() { return array(); @@ -266,7 +273,7 @@ abstract class DatabaseInstaller { $up = DatabaseUpdater::newForDB( $this->db ); $up->doUpdates(); } catch ( MWException $e ) { - echo "\nAn error occured:\n"; + echo "\nAn error occurred:\n"; echo $e->getText(); $ret = false; } @@ -292,6 +299,7 @@ abstract class DatabaseInstaller { /** * Get an array of MW configuration globals that will be configured by this class. + * @return array */ public function getGlobalNames() { return $this->globalNames; @@ -300,6 +308,7 @@ abstract class DatabaseInstaller { /** * Construct and initialise parent. * This is typically only called from Installer::getDBInstaller() + * @param $parent */ public function __construct( $parent ) { $this->parent = $parent; @@ -310,6 +319,8 @@ abstract class DatabaseInstaller { * Check if a named extension is present. * * @see wfDl + * @param $name + * @return bool */ protected static function checkExtension( $name ) { wfSuppressWarnings(); @@ -320,6 +331,7 @@ abstract class DatabaseInstaller { /** * Get the internationalised name for this DBMS. + * @return String */ public function getReadableName() { return wfMsg( 'config-type-' . $this->getName() ); @@ -328,6 +340,7 @@ abstract class DatabaseInstaller { /** * Get a name=>value map of MW configuration globals that overrides. * DefaultSettings.php + * @return array */ public function getGlobalDefaults() { return array(); @@ -335,6 +348,7 @@ abstract class DatabaseInstaller { /** * Get a name=>value map of internal variables used during installation. + * @return array */ public function getInternalDefaults() { return $this->internalDefaults; @@ -342,6 +356,9 @@ abstract class DatabaseInstaller { /** * Get a variable, taking local defaults into account. + * @param $var string + * @param $default null + * @return mixed */ public function getVar( $var, $default = null ) { $defaults = $this->getGlobalDefaults(); @@ -356,6 +373,8 @@ abstract class DatabaseInstaller { /** * Convenience alias for $this->parent->setVar() + * @param $name string + * @param $value mixed */ public function setVar( $name, $value ) { $this->parent->setVar( $name, $value ); @@ -364,6 +383,10 @@ abstract class DatabaseInstaller { /** * Get a labelled text box to configure a local variable. * + * @param $var string + * @param $label string + * @param $attribs array + * @param $helpData string * @return string */ public function getTextBox( $var, $label, $attribs = array(), $helpData = "" ) { @@ -386,6 +409,10 @@ abstract class DatabaseInstaller { * 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 * @return string */ public function getPasswordBox( $var, $label, $attribs = array(), $helpData = "" ) { @@ -433,6 +460,7 @@ abstract class DatabaseInstaller { * values: List of allowed values (required) * itemAttribs Array of attribute arrays, outer key is the value name (optional) * + * @return string */ public function getRadioSet( $params ) { $params['controlName'] = $this->getName() . '_' . $params['var']; @@ -445,6 +473,7 @@ abstract class DatabaseInstaller { * Assumes that variables containing "password" in the name are (potentially * fake) passwords. * @param $varNames Array + * @return array */ public function setVarsFromRequest( $varNames ) { return $this->parent->setVarsFromRequest( $varNames, $this->getName() . '_' ); @@ -469,7 +498,7 @@ abstract class DatabaseInstaller { if ( !$this->db->selectDB( $this->getVar( 'wgDBname' ) ) ) { return false; } - return $this->db->tableExists( 'cur' ) || $this->db->tableExists( 'revision' ); + return $this->db->tableExists( 'cur', __METHOD__ ) || $this->db->tableExists( 'revision', __METHOD__ ); } /** @@ -481,13 +510,14 @@ abstract class DatabaseInstaller { return Html::openElement( 'fieldset' ) . Html::element( 'legend', array(), wfMsg( 'config-db-install-account' ) ) . - $this->getTextBox( '_InstallUser', 'config-db-username', array(), $this->parent->getHelpBox( 'config-db-install-username' ) ) . - $this->getPasswordBox( '_InstallPassword', 'config-db-password', array(), $this->parent->getHelpBox( 'config-db-install-password' ) ) . + $this->getTextBox( '_InstallUser', 'config-db-username', array( 'dir' => 'ltr' ), $this->parent->getHelpBox( 'config-db-install-username' ) ) . + $this->getPasswordBox( '_InstallPassword', 'config-db-password', array( 'dir' => 'ltr' ), $this->parent->getHelpBox( 'config-db-install-password' ) ) . Html::closeElement( 'fieldset' ); } /** * Submit a standard install user fieldset. + * @return Status */ public function submitInstallUserBox() { $this->setVarsFromRequest( array( '_InstallUser', '_InstallPassword' ) );