8d6ebb614a5ad84154792f96d28d3ea3ca8beffb
3 * Oracle-specific installer.
10 * Class for setting up the MediaWiki database using Oracle.
15 class OracleInstaller
extends DatabaseInstaller
{
17 protected $globalNames = array(
25 protected $internalDefaults = array(
26 '_OracleDefTS' => 'USERS',
27 '_OracleTempTS' => 'TEMP'
30 protected $useSysDBA = false;
32 public $minimumVersion = '9.0.1'; // 9iR1
34 public function getName() {
38 public function isCompiled() {
39 return self
::checkExtension( 'oci8' );
42 public function getWebUserBox( $noCreateMsg = false ) {
43 $this->parent
->setVar( '_SameAccount', false );
44 $this->parent
->setVar( '_CreateDBAccount', true );
45 $this->parent
->setVar( 'wgDBname', '' );
46 return Html
::openElement( 'fieldset' ) .
47 Html
::element( 'legend', array(), wfMsg( 'config-db-web-account' ) ) .
48 Html
::openElement( 'div', array( 'id' => 'dbOtherAccount' ) ) .
49 $this->getTextBox( 'wgDBuser', 'config-db-username' ) .
50 $this->getPasswordBox( 'wgDBpassword', 'config-db-password', array(), $this->parent
->getHelpBox( 'config-db-web-help' ) ) .
51 $this->getCheckBox( '_CreateDBAccount', 'config-db-web-create', array( 'disabled' => true ) ).
52 Html
::closeElement( 'div' ) . Html
::closeElement( 'fieldset' );
55 public function getConnectForm() {
56 $this->parent
->setVar( '_InstallUser', 'sys' );
57 $this->parent
->setVar( 'wgDBserver', '' );
59 $this->getTextBox( 'wgDBserver', 'config-db-host-oracle', array(), $this->parent
->getHelpBox( 'config-db-host-oracle-help' ) ) .
60 Html
::openElement( 'fieldset' ) .
61 Html
::element( 'legend', array(), wfMsg( 'config-db-wiki-settings' ) ) .
62 $this->getTextBox( 'wgDBprefix', 'config-db-prefix' ) .
63 $this->getTextBox( '_OracleDefTS', 'config-oracle-def-ts' ) .
64 $this->getTextBox( '_OracleTempTS', 'config-oracle-temp-ts', array(), $this->parent
->getHelpBox( 'config-db-oracle-help' ) ) .
65 Html
::closeElement( 'fieldset' ) .
66 $this->getInstallUserBox().
67 $this->getWebUserBox();
70 public function submitConnectForm() {
71 // Get variables from the request
72 $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBprefix', 'wgDBuser', 'wgDBpassword' ) );
73 $this->parent
->setVar( 'wgDBname', $this->getVar( 'wgDBuser' ) );
76 $status = Status
::newGood();
77 if ( !strlen( $newValues['wgDBserver'] ) ) {
78 $status->fatal( 'config-missing-db-server-oracle' );
79 } elseif ( !preg_match( '/^[a-zA-Z0-9_\.]+$/', $newValues['wgDBserver'] ) ) {
80 $status->fatal( 'config-invalid-db-server-oracle', $newValues['wgDBserver'] );
82 if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBprefix'] ) ) {
83 $status->fatal( 'config-invalid-schema', $newValues['wgDBprefix'] );
85 if ( !$status->isOK() ) {
90 $status = $this->submitInstallUserBox();
91 if ( !$status->isOK() ) {
96 $this->useSysDBA
= true;
97 $status = $this->getConnection();
98 if ( !$status->isOK() ) {
101 $conn = $status->value
;
104 $version = $conn->getServerVersion();
105 if ( version_compare( $version, $this->minimumVersion
) < 0 ) {
106 return Status
::newFatal( 'config-oracle-old', $this->minimumVersion
, $version );
112 public function openConnection() {
113 $status = Status
::newGood();
115 if ( $this->useSysDBA
) {
116 $db = new DatabaseOracle(
117 $this->getVar( 'wgDBserver' ),
118 $this->getVar( '_InstallUser' ),
119 $this->getVar( '_InstallPassword' ),
120 $this->getVar( 'wgDBname' ),
121 DBO_SYSDBA | DBO_DDLMODE
,
122 $this->getVar( 'wgDBprefix' )
125 $db = new DatabaseOracle(
126 $this->getVar( 'wgDBserver' ),
127 $this->getVar( 'wgDBuser' ),
128 $this->getVar( 'wgDBpassword' ),
129 $this->getVar( 'wgDBname' ),
131 $this->getVar( 'wgDBprefix' )
134 $status->value
= $db;
135 } catch ( DBConnectionError
$e ) {
136 $status->fatal( 'config-connection-error', $e->getMessage() );
141 public function needsUpgrade() {
142 $tempDBname = $this->getVar( 'wgDBname' );
143 $this->parent
->setVar( 'wgDBname', $this->getVar( 'wgDBuser' ) );
144 $retVal = parent
::needsUpgrade();
145 $this->parent
->setVar( 'wgDBname', $tempDBname );
149 public function preInstall() {
150 # Add our user callback to installSteps, right before the tables are created.
153 'callback' => array( $this, 'setupUser' )
155 $this->parent
->addInstallStep( $callback, 'database' );
159 public function setupDatabase() {
160 $this->useSysDBA
= false;
161 $status = Status
::newGood();
165 public function setupUser() {
168 if ( !$this->getVar( '_CreateDBAccount' ) ) {
169 return Status
::newGood();
172 $this->useSysDBA
= true;
173 $status = $this->getConnection();
174 if ( !$status->isOK() ) {
178 if ( !$this->db
->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
179 $this->db
->setFlag( DBO_DDLMODE
);
180 $error = $this->db
->sourceFile( "$IP/maintenance/oracle/user.sql" );
181 if ( $error !== true ||
!$this->db
->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
182 $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $error );
190 * Overload: after this action field info table has to be rebuilt
192 public function createTables() {
193 $status = parent
::createTables();
195 $this->db
->query( 'BEGIN fill_wiki_info; END;' );
200 public function getSchemaVars() {
202 * The variables $_OracleDefTS, $_OracleTempTS are used by maintenance/oracle/user.sql
205 '_OracleDefTS' => $this->getVar( '_OracleDefTS' ),
206 '_OracleTempTS' => $this->getVar( '_OracleTempTS' ),
210 public function getLocalSettings() {
211 $prefix = $this->getVar( 'wgDBprefix' );
213 "# Oracle specific settings
214 \$wgDBprefix = \"{$prefix}\";