r69601 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69600‎ | r69601 | r69602 >
Date:11:17, 20 July 2010
Author:jeroendedauw
Status:ok
Tags:
Comment:
Doc and style improvements
Modified paths:
  • /trunk/phase3/includes/installer/DatabaseInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/DatabaseInstaller.php
@@ -5,16 +5,34 @@
66 */
77 abstract class DatabaseInstaller {
88
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+ */
1016 public $parent;
1117
12 - /* Database connection */
 18+ /**
 19+ * The database connection.
 20+ *
 21+ * @var DatabaseBase
 22+ */
1323 public $db;
1424
15 - /** Internal variables for installation */
 25+ /**
 26+ * Internal variables for installation.
 27+ *
 28+ * @var array
 29+ */
1630 protected $internalDefaults = array();
1731
18 - /** Array of MW configuration globals this class uses */
 32+ /**
 33+ * Array of MW configuration globals this class uses.
 34+ *
 35+ * @var array
 36+ */
1937 protected $globalNames = array();
2038
2139 /**
@@ -28,18 +46,11 @@
2947 public abstract function isCompiled();
3048
3149 /**
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 - /**
3950 * Get HTML for a web form that configures this database. Configuration
4051 * at this time should be the minimum needed to connect and test
4152 * whether install or upgrade is required.
4253 *
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.
4455 */
4556 public abstract function getConnectForm();
4657
@@ -48,7 +59,7 @@
4960 * via the form returned by getConnectForm(). Validate the connection
5061 * settings by attempting to connect with them.
5162 *
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.
5364 *
5465 * @return Status
5566 */
@@ -65,6 +76,7 @@
6677 /**
6778 * Set variables based on the request array, assuming it was submitted via
6879 * the form return by getSettingsForm().
 80+ *
6981 * @return Status
7082 */
7183 public abstract function submitSettingsForm();
@@ -77,15 +89,8 @@
7890 * This may be called multiple times, so the result should be cached.
7991 */
8092 public abstract function getConnection();
81 -
 93+
8294 /**
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 - /**
9095 * Create the database and return a Status object indicating success or
9196 * failure.
9297 *
@@ -94,34 +99,53 @@
95100 public abstract function setupDatabase();
96101
97102 /**
98 - * Create database tables from scratch
 103+ * Create database tables from scratch.
 104+ *
99105 * @return \type Status
100106 */
101107 public abstract function createTables();
102108
103109 /**
 110+ * Get the DBMS-specific options for LocalSettings.php generation.
 111+ *
 112+ * @return String
 113+ */
 114+ public abstract function getLocalSettings();
 115+
 116+ /**
104117 * Perform database upgrades
105118 * @todo make abstract
106119 */
107120 /*abstract*/ function doUpgrade() {
108121 return false;
109122 }
 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+ }
110132
111133 /**
 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+ /**
112141 * Return any table options to be applied to all tables that don't
113 - * override them
 142+ * override them.
 143+ *
114144 * @return Array
115145 */
116146 public function getTableOptions() {
117147 return array();
118148 }
119149
120 - /**
121 - * Get the DBMS-specific options for LocalSettings.php generation.
122 - * @return String
123 - */
124 - public abstract function getLocalSettings();
125 -
126150 /**
127151 * Construct and initialise parent.
128152 * This is typically only called from Installer::getDBInstaller()
@@ -131,8 +155,10 @@
132156 }
133157
134158 /**
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
137163 */
138164 protected static function checkExtension( $name ) {
139165 wfSuppressWarnings();
@@ -142,14 +168,14 @@
143169 }
144170
145171 /**
146 - * Get the internationalised name for this DBMS
 172+ * Get the internationalised name for this DBMS.
147173 */
148174 public function getReadableName() {
149175 return wfMsg( 'config-type-' . $this->getName() );
150176 }
151177
152178 /**
153 - * Get a name=>value map of MW configuration globals that overrides
 179+ * Get a name=>value map of MW configuration globals that overrides.
154180 * DefaultSettings.php
155181 */
156182 public function getGlobalDefaults() {
@@ -157,14 +183,14 @@
158184 }
159185
160186 /**
161 - * Get a name=>value map of internal variables used during installation
 187+ * Get a name=>value map of internal variables used during installation.
162188 */
163189 public function getInternalDefaults() {
164190 return $this->internalDefaults;
165191 }
166192
167193 /**
168 - * Get a variable, taking local defaults into account
 194+ * Get a variable, taking local defaults into account.
169195 */
170196 public function getVar( $var, $default = null ) {
171197 $defaults = $this->getGlobalDefaults();
@@ -185,7 +211,7 @@
186212 }
187213
188214 /**
189 - * Get a labelled text box to configure a local variable
 215+ * Get a labelled text box to configure a local variable.
190216 */
191217 public function getTextBox( $var, $label, $attribs = array() ) {
192218 $name = $this->getName() . '_' . $var;
@@ -200,8 +226,8 @@
201227 }
202228
203229 /**
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.
206232 */
207233 public function getPasswordBox( $var, $label, $attribs = array() ) {
208234 $name = $this->getName() . '_' . $var;
@@ -216,7 +242,7 @@
217243 }
218244
219245 /**
220 - * Get a labelled checkbox to configure a local boolean variable
 246+ * Get a labelled checkbox to configure a local boolean variable.
221247 */
222248 public function getCheckBox( $var, $label, $attribs = array() ) {
223249 $name = $this->getName() . '_' . $var;
@@ -231,7 +257,7 @@
232258 }
233259
234260 /**
235 - * Get a set of labelled radio buttons
 261+ * Get a set of labelled radio buttons.
236262 *
237263 * @param $params Array:
238264 * Parameters are:
@@ -281,7 +307,7 @@
282308 }
283309
284310 /**
285 - * Get a standard install-user fieldset
 311+ * Get a standard install-user fieldset.
286312 */
287313 public function getInstallUserBox() {
288314 return
@@ -294,7 +320,7 @@
295321 }
296322
297323 /**
298 - * Submit a standard install user fieldset
 324+ * Submit a standard install user fieldset.
299325 */
300326 public function submitInstallUserBox() {
301327 $this->setVarsFromRequest( array( '_InstallUser', '_InstallPassword' ) );
@@ -329,20 +355,24 @@
330356
331357 /**
332358 * Submit the form from getWebUserBox().
 359+ *
333360 * @return Status
334361 */
335362 public function submitWebUserBox() {
336 - $this->setVarsFromRequest( array( 'wgDBuser', 'wgDBpassword',
337 - '_SameAccount', '_CreateDBAccount' ) );
 363+ $this->setVarsFromRequest(
 364+ array( 'wgDBuser', 'wgDBpassword', '_SameAccount', '_CreateDBAccount' )
 365+ );
 366+
338367 if ( $this->getVar( '_SameAccount' ) ) {
339368 $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
340369 $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
341370 }
 371+
342372 return Status::newGood();
343373 }
344374
345375 /**
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.
347377 */
348378 public function populateInterwikiTable() {
349379 $status = $this->getConnection();

Status & tagging log