Index: trunk/phase3/includes/installer/DatabaseInstaller.php |
— | — | @@ -5,16 +5,34 @@ |
6 | 6 | */ |
7 | 7 | abstract class DatabaseInstaller { |
8 | 8 | |
9 | | - /** The Installer object */ |
| 9 | + /** |
| 10 | + * The Installer object. |
| 11 | + * |
| 12 | + * TODO: naming this parent is confusing, 'installer' would be clearer. |
| 13 | + * |
| 14 | + * @var Installer |
| 15 | + */ |
10 | 16 | public $parent; |
11 | 17 | |
12 | | - /* Database connection */ |
| 18 | + /** |
| 19 | + * The database connection. |
| 20 | + * |
| 21 | + * @var DatabaseBase |
| 22 | + */ |
13 | 23 | public $db; |
14 | 24 | |
15 | | - /** Internal variables for installation */ |
| 25 | + /** |
| 26 | + * Internal variables for installation. |
| 27 | + * |
| 28 | + * @var array |
| 29 | + */ |
16 | 30 | protected $internalDefaults = array(); |
17 | 31 | |
18 | | - /** Array of MW configuration globals this class uses */ |
| 32 | + /** |
| 33 | + * Array of MW configuration globals this class uses. |
| 34 | + * |
| 35 | + * @var array |
| 36 | + */ |
19 | 37 | protected $globalNames = array(); |
20 | 38 | |
21 | 39 | /** |
— | — | @@ -28,18 +46,11 @@ |
29 | 47 | public abstract function isCompiled(); |
30 | 48 | |
31 | 49 | /** |
32 | | - * Get an array of MW configuration globals that will be configured by this class. |
33 | | - */ |
34 | | - public function getGlobalNames() { |
35 | | - return $this->globalNames; |
36 | | - } |
37 | | - |
38 | | - /** |
39 | 50 | * Get HTML for a web form that configures this database. Configuration |
40 | 51 | * at this time should be the minimum needed to connect and test |
41 | 52 | * whether install or upgrade is required. |
42 | 53 | * |
43 | | - * If this is called, $this->parent can be assumed to be a WebInstaller |
| 54 | + * If this is called, $this->parent can be assumed to be a WebInstaller. |
44 | 55 | */ |
45 | 56 | public abstract function getConnectForm(); |
46 | 57 | |
— | — | @@ -48,7 +59,7 @@ |
49 | 60 | * via the form returned by getConnectForm(). Validate the connection |
50 | 61 | * settings by attempting to connect with them. |
51 | 62 | * |
52 | | - * If this is called, $this->parent can be assumed to be a WebInstaller |
| 63 | + * If this is called, $this->parent can be assumed to be a WebInstaller. |
53 | 64 | * |
54 | 65 | * @return Status |
55 | 66 | */ |
— | — | @@ -65,6 +76,7 @@ |
66 | 77 | /** |
67 | 78 | * Set variables based on the request array, assuming it was submitted via |
68 | 79 | * the form return by getSettingsForm(). |
| 80 | + * |
69 | 81 | * @return Status |
70 | 82 | */ |
71 | 83 | public abstract function submitSettingsForm(); |
— | — | @@ -77,15 +89,8 @@ |
78 | 90 | * This may be called multiple times, so the result should be cached. |
79 | 91 | */ |
80 | 92 | public abstract function getConnection(); |
81 | | - |
| 93 | + |
82 | 94 | /** |
83 | | - * Allow DB installers a chance to make last-minute changes before installation |
84 | | - * occurs. This happens before setupDatabase() or createTables() is called, but |
85 | | - * long after the constructor. Helpful for things like modifying setup steps :) |
86 | | - */ |
87 | | - public function preInstall() {} |
88 | | - |
89 | | - /** |
90 | 95 | * Create the database and return a Status object indicating success or |
91 | 96 | * failure. |
92 | 97 | * |
— | — | @@ -94,34 +99,53 @@ |
95 | 100 | public abstract function setupDatabase(); |
96 | 101 | |
97 | 102 | /** |
98 | | - * Create database tables from scratch |
| 103 | + * Create database tables from scratch. |
| 104 | + * |
99 | 105 | * @return \type Status |
100 | 106 | */ |
101 | 107 | public abstract function createTables(); |
102 | 108 | |
103 | 109 | /** |
| 110 | + * Get the DBMS-specific options for LocalSettings.php generation. |
| 111 | + * |
| 112 | + * @return String |
| 113 | + */ |
| 114 | + public abstract function getLocalSettings(); |
| 115 | + |
| 116 | + /** |
104 | 117 | * Perform database upgrades |
105 | 118 | * @todo make abstract |
106 | 119 | */ |
107 | 120 | /*abstract*/ function doUpgrade() { |
108 | 121 | return false; |
109 | 122 | } |
| 123 | + |
| 124 | + /** |
| 125 | + * Allow DB installers a chance to make last-minute changes before installation |
| 126 | + * occurs. This happens before setupDatabase() or createTables() is called, but |
| 127 | + * long after the constructor. Helpful for things like modifying setup steps :) |
| 128 | + */ |
| 129 | + public function preInstall() { |
| 130 | + |
| 131 | + } |
110 | 132 | |
111 | 133 | /** |
| 134 | + * Get an array of MW configuration globals that will be configured by this class. |
| 135 | + */ |
| 136 | + public function getGlobalNames() { |
| 137 | + return $this->globalNames; |
| 138 | + } |
| 139 | + |
| 140 | + /** |
112 | 141 | * Return any table options to be applied to all tables that don't |
113 | | - * override them |
| 142 | + * override them. |
| 143 | + * |
114 | 144 | * @return Array |
115 | 145 | */ |
116 | 146 | public function getTableOptions() { |
117 | 147 | return array(); |
118 | 148 | } |
119 | 149 | |
120 | | - /** |
121 | | - * Get the DBMS-specific options for LocalSettings.php generation. |
122 | | - * @return String |
123 | | - */ |
124 | | - public abstract function getLocalSettings(); |
125 | | - |
126 | 150 | /** |
127 | 151 | * Construct and initialise parent. |
128 | 152 | * This is typically only called from Installer::getDBInstaller() |
— | — | @@ -131,8 +155,10 @@ |
132 | 156 | } |
133 | 157 | |
134 | 158 | /** |
135 | | - * Convenience function |
136 | | - * Check if a named extension is present |
| 159 | + * Convenience function. |
| 160 | + * Check if a named extension is present. |
| 161 | + * |
| 162 | + * @see wfDl |
137 | 163 | */ |
138 | 164 | protected static function checkExtension( $name ) { |
139 | 165 | wfSuppressWarnings(); |
— | — | @@ -142,14 +168,14 @@ |
143 | 169 | } |
144 | 170 | |
145 | 171 | /** |
146 | | - * Get the internationalised name for this DBMS |
| 172 | + * Get the internationalised name for this DBMS. |
147 | 173 | */ |
148 | 174 | public function getReadableName() { |
149 | 175 | return wfMsg( 'config-type-' . $this->getName() ); |
150 | 176 | } |
151 | 177 | |
152 | 178 | /** |
153 | | - * Get a name=>value map of MW configuration globals that overrides |
| 179 | + * Get a name=>value map of MW configuration globals that overrides. |
154 | 180 | * DefaultSettings.php |
155 | 181 | */ |
156 | 182 | public function getGlobalDefaults() { |
— | — | @@ -157,14 +183,14 @@ |
158 | 184 | } |
159 | 185 | |
160 | 186 | /** |
161 | | - * Get a name=>value map of internal variables used during installation |
| 187 | + * Get a name=>value map of internal variables used during installation. |
162 | 188 | */ |
163 | 189 | public function getInternalDefaults() { |
164 | 190 | return $this->internalDefaults; |
165 | 191 | } |
166 | 192 | |
167 | 193 | /** |
168 | | - * Get a variable, taking local defaults into account |
| 194 | + * Get a variable, taking local defaults into account. |
169 | 195 | */ |
170 | 196 | public function getVar( $var, $default = null ) { |
171 | 197 | $defaults = $this->getGlobalDefaults(); |
— | — | @@ -185,7 +211,7 @@ |
186 | 212 | } |
187 | 213 | |
188 | 214 | /** |
189 | | - * Get a labelled text box to configure a local variable |
| 215 | + * Get a labelled text box to configure a local variable. |
190 | 216 | */ |
191 | 217 | public function getTextBox( $var, $label, $attribs = array() ) { |
192 | 218 | $name = $this->getName() . '_' . $var; |
— | — | @@ -200,8 +226,8 @@ |
201 | 227 | } |
202 | 228 | |
203 | 229 | /** |
204 | | - * Get a labelled password box to configure a local variable |
205 | | - * Implements password hiding |
| 230 | + * Get a labelled password box to configure a local variable. |
| 231 | + * Implements password hiding. |
206 | 232 | */ |
207 | 233 | public function getPasswordBox( $var, $label, $attribs = array() ) { |
208 | 234 | $name = $this->getName() . '_' . $var; |
— | — | @@ -216,7 +242,7 @@ |
217 | 243 | } |
218 | 244 | |
219 | 245 | /** |
220 | | - * Get a labelled checkbox to configure a local boolean variable |
| 246 | + * Get a labelled checkbox to configure a local boolean variable. |
221 | 247 | */ |
222 | 248 | public function getCheckBox( $var, $label, $attribs = array() ) { |
223 | 249 | $name = $this->getName() . '_' . $var; |
— | — | @@ -231,7 +257,7 @@ |
232 | 258 | } |
233 | 259 | |
234 | 260 | /** |
235 | | - * Get a set of labelled radio buttons |
| 261 | + * Get a set of labelled radio buttons. |
236 | 262 | * |
237 | 263 | * @param $params Array: |
238 | 264 | * Parameters are: |
— | — | @@ -281,7 +307,7 @@ |
282 | 308 | } |
283 | 309 | |
284 | 310 | /** |
285 | | - * Get a standard install-user fieldset |
| 311 | + * Get a standard install-user fieldset. |
286 | 312 | */ |
287 | 313 | public function getInstallUserBox() { |
288 | 314 | return |
— | — | @@ -294,7 +320,7 @@ |
295 | 321 | } |
296 | 322 | |
297 | 323 | /** |
298 | | - * Submit a standard install user fieldset |
| 324 | + * Submit a standard install user fieldset. |
299 | 325 | */ |
300 | 326 | public function submitInstallUserBox() { |
301 | 327 | $this->setVarsFromRequest( array( '_InstallUser', '_InstallPassword' ) ); |
— | — | @@ -329,20 +355,24 @@ |
330 | 356 | |
331 | 357 | /** |
332 | 358 | * Submit the form from getWebUserBox(). |
| 359 | + * |
333 | 360 | * @return Status |
334 | 361 | */ |
335 | 362 | public function submitWebUserBox() { |
336 | | - $this->setVarsFromRequest( array( 'wgDBuser', 'wgDBpassword', |
337 | | - '_SameAccount', '_CreateDBAccount' ) ); |
| 363 | + $this->setVarsFromRequest( |
| 364 | + array( 'wgDBuser', 'wgDBpassword', '_SameAccount', '_CreateDBAccount' ) |
| 365 | + ); |
| 366 | + |
338 | 367 | if ( $this->getVar( '_SameAccount' ) ) { |
339 | 368 | $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) ); |
340 | 369 | $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) ); |
341 | 370 | } |
| 371 | + |
342 | 372 | return Status::newGood(); |
343 | 373 | } |
344 | 374 | |
345 | 375 | /** |
346 | | - * Common function for databases that don't understand the MySQLish syntax of interwiki.sql |
| 376 | + * Common function for databases that don't understand the MySQLish syntax of interwiki.sql. |
347 | 377 | */ |
348 | 378 | public function populateInterwikiTable() { |
349 | 379 | $status = $this->getConnection(); |