* Make the MySQL updater work in the new installer
[lhc/web/wiklou.git] / includes / installer / OracleInstaller.php
1 <?php
2 /**
3 * Oracle-specific installer.
4 *
5 * @file
6 * @ingroup Deployment
7 */
8
9 /**
10 * Class for setting up the MediaWiki database using Oracle.
11 *
12 * @ingroup Deployment
13 * @since 1.17
14 */
15 class OracleInstaller extends DatabaseInstaller {
16
17 protected $globalNames = array(
18 'wgDBport',
19 'wgDBname',
20 'wgDBuser',
21 'wgDBpassword',
22 'wgDBprefix',
23 );
24
25 protected $internalDefaults = array(
26 '_InstallUser' => 'sys',
27 '_InstallPassword' => '',
28 );
29
30 public function getName() {
31 return 'oracle';
32 }
33
34 public function isCompiled() {
35 return self::checkExtension( 'oci8' );
36 }
37
38 public function getConnectForm() {
39 return
40 Xml::openElement( 'fieldset' ) .
41 Xml::element( 'legend', array(), wfMsg( 'config-db-wiki-settings' ) ) .
42 $this->getTextBox( 'wgDBname', 'config-db-name' ) .
43 $this->parent->getHelpBox( 'config-db-name-help' ) .
44 $this->getTextBox( 'wgDBprefix', 'config-db-prefix' ) .
45 $this->parent->getHelpBox( 'config-db-prefix-help' ) .
46 Xml::closeElement( 'fieldset' ) .
47 $this->getInstallUserBox();
48 }
49
50 public function submitConnectForm() {
51 // Get variables from the request
52 $newValues = $this->setVarsFromRequest( array( 'wgDBname', 'wgDBprefix' ) );
53
54 // Validate them
55 $status = Status::newGood();
56 if ( !strlen( $newValues['wgDBname'] ) ) {
57 $status->fatal( 'config-missing-db-name' );
58 } elseif ( !preg_match( '/^[a-zA-Z0-9_]+$/', $newValues['wgDBname'] ) ) {
59 $status->fatal( 'config-invalid-db-name', $newValues['wgDBname'] );
60 }
61 if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBprefix'] ) ) {
62 $status->fatal( 'config-invalid-schema', $newValues['wgDBprefix'] );
63 }
64
65 // Submit user box
66 if ( $status->isOK() ) {
67 $status->merge( $this->submitInstallUserBox() );
68 }
69 if ( !$status->isOK() ) {
70 return $status;
71 }
72
73 // Try to connect
74 if ( $status->isOK() ) {
75 $status->merge( $this->attemptConnection() );
76 }
77 if ( !$status->isOK() ) {
78 return $status;
79 }
80
81 // Check version
82 /*
83 $version = $this->conn->getServerVersion();
84 if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
85 return Status::newFatal( 'config-postgres-old', $this->minimumVersion, $version );
86 }
87 */
88 return $status;
89 }
90
91
92 public function getSettingsForm() {
93 // TODO
94 }
95
96 public function submitSettingsForm() {
97 // TODO
98 }
99
100 public function getConnection() {
101 // TODO
102 }
103
104 public function setupDatabase() {
105 // TODO
106 }
107
108 public function createTables() {
109 // TODO
110 }
111
112 public function getLocalSettings() {
113 $prefix = $this->getVar( 'wgDBprefix' );
114 return
115 "# Oracle specific settings
116 \$wgDBprefix = \"{$prefix}\";";
117 }
118
119 public function doUpgrade() {
120 // TODO
121 return false;
122 }
123 }