r69592 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69591‎ | r69592 | r69593 >
Date:09:49, 20 July 2010
Author:jeroendedauw
Status:reverted
Tags:
Comment:
Follow up to r69589
Modified paths:
  • /trunk/phase3/includes/installer/DatabaseInstaller.php (added) (history)
  • /trunk/phase3/includes/installer/InstallerDBType.php (deleted) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/InstallerDBType.php
@@ -1,377 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Base class for DBMS-specific installation helper classes.
6 - */
7 -abstract class DatabaseInstaller {
8 -
9 - /** The Installer object */
10 - public $parent;
11 -
12 - /* Database connection */
13 - public $db;
14 -
15 - /** Internal variables for installation */
16 - protected $internalDefaults = array();
17 -
18 - /** Array of MW configuration globals this class uses */
19 - protected $globalNames = array();
20 -
21 - /**
22 - * Return the internal name, e.g. 'mysql', or 'sqlite'.
23 - */
24 - public abstract function getName();
25 -
26 - /**
27 - * @return true if the client library is compiled in.
28 - */
29 - public abstract function isCompiled();
30 -
31 - /**
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 - * Get HTML for a web form that configures this database. Configuration
40 - * at this time should be the minimum needed to connect and test
41 - * whether install or upgrade is required.
42 - *
43 - * If this is called, $this->parent can be assumed to be a WebInstaller
44 - */
45 - public abstract function getConnectForm();
46 -
47 - /**
48 - * Set variables based on the request array, assuming it was submitted
49 - * via the form returned by getConnectForm(). Validate the connection
50 - * settings by attempting to connect with them.
51 - *
52 - * If this is called, $this->parent can be assumed to be a WebInstaller
53 - *
54 - * @return Status
55 - */
56 - public abstract function submitConnectForm();
57 -
58 - /**
59 - * Get HTML for a web form that retrieves settings used for installation.
60 - * $this->parent can be assumed to be a WebInstaller.
61 - * If the DB type has no settings beyond those already configured with
62 - * getConnectForm(), this should return false.
63 - */
64 - public abstract function getSettingsForm();
65 -
66 - /**
67 - * Set variables based on the request array, assuming it was submitted via
68 - * the form return by getSettingsForm().
69 - * @return Status
70 - */
71 - public abstract function submitSettingsForm();
72 -
73 - /**
74 - * Connect to the database using the administrative user/password currently
75 - * defined in the session. On success, return the connection, on failure,
76 - * return a Status object.
77 - *
78 - * This may be called multiple times, so the result should be cached.
79 - */
80 - public abstract function getConnection();
81 -
82 - /**
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 - * Create the database and return a Status object indicating success or
91 - * failure.
92 - *
93 - * @return Status
94 - */
95 - public abstract function setupDatabase();
96 -
97 - /**
98 - * Create database tables from scratch
99 - * @return \type Status
100 - */
101 - public abstract function createTables();
102 -
103 - /**
104 - * Perform database upgrades
105 - * @todo make abstract
106 - */
107 - /*abstract*/ function doUpgrade() {
108 - return false;
109 - }
110 -
111 - /**
112 - * Return any table options to be applied to all tables that don't
113 - * override them
114 - * @return Array
115 - */
116 - public function getTableOptions() {
117 - return array();
118 - }
119 -
120 - /**
121 - * Get the DBMS-specific options for LocalSettings.php generation.
122 - * @return String
123 - */
124 - public abstract function getLocalSettings();
125 -
126 - /**
127 - * Construct and initialise parent.
128 - * This is typically only called from Installer::getDBInstaller()
129 - */
130 - public function __construct( $parent ) {
131 - $this->parent = $parent;
132 - }
133 -
134 - /**
135 - * Convenience function
136 - * Check if a named extension is present
137 - */
138 - protected static function checkExtension( $name ) {
139 - wfSuppressWarnings();
140 - $compiled = wfDl( $name );
141 - wfRestoreWarnings();
142 - return $compiled;
143 - }
144 -
145 - /**
146 - * Get the internationalised name for this DBMS
147 - */
148 - public function getReadableName() {
149 - return wfMsg( 'config-type-' . $this->getName() );
150 - }
151 -
152 - /**
153 - * Get a name=>value map of MW configuration globals that overrides
154 - * DefaultSettings.php
155 - */
156 - public function getGlobalDefaults() {
157 - return array();
158 - }
159 -
160 - /**
161 - * Get a name=>value map of internal variables used during installation
162 - */
163 - public function getInternalDefaults() {
164 - return $this->internalDefaults;
165 - }
166 -
167 - /**
168 - * Get a variable, taking local defaults into account
169 - */
170 - public function getVar( $var, $default = null ) {
171 - $defaults = $this->getGlobalDefaults();
172 - $internal = $this->getInternalDefaults();
173 - if ( isset( $defaults[$var] ) ) {
174 - $default = $defaults[$var];
175 - } elseif ( isset( $internal[$var] ) ) {
176 - $default = $internal[$var];
177 - }
178 - return $this->parent->getVar( $var, $default );
179 - }
180 -
181 - /**
182 - * Convenience alias for $this->parent->setVar()
183 - */
184 - public function setVar( $name, $value ) {
185 - $this->parent->setVar( $name, $value );
186 - }
187 -
188 - /**
189 - * Get a labelled text box to configure a local variable
190 - */
191 - public function getTextBox( $var, $label, $attribs = array() ) {
192 - $name = $this->getName() . '_' . $var;
193 - $value = $this->getVar( $var );
194 - return $this->parent->getTextBox( array(
195 - 'var' => $var,
196 - 'label' => $label,
197 - 'attribs' => $attribs,
198 - 'controlName' => $name,
199 - 'value' => $value
200 - ) );
201 - }
202 -
203 - /**
204 - * Get a labelled password box to configure a local variable
205 - * Implements password hiding
206 - */
207 - public function getPasswordBox( $var, $label, $attribs = array() ) {
208 - $name = $this->getName() . '_' . $var;
209 - $value = $this->getVar( $var );
210 - return $this->parent->getPasswordBox( array(
211 - 'var' => $var,
212 - 'label' => $label,
213 - 'attribs' => $attribs,
214 - 'controlName' => $name,
215 - 'value' => $value
216 - ) );
217 - }
218 -
219 - /**
220 - * Get a labelled checkbox to configure a local boolean variable
221 - */
222 - public function getCheckBox( $var, $label, $attribs = array() ) {
223 - $name = $this->getName() . '_' . $var;
224 - $value = $this->getVar( $var );
225 - return $this->parent->getCheckBox( array(
226 - 'var' => $var,
227 - 'label' => $label,
228 - 'attribs' => $attribs,
229 - 'controlName' => $name,
230 - 'value' => $value,
231 - ));
232 - }
233 -
234 - /**
235 - * Get a set of labelled radio buttons
236 - *
237 - * @param $params Array:
238 - * Parameters are:
239 - * var: The variable to be configured (required)
240 - * label: The message name for the label (required)
241 - * itemLabelPrefix: The message name prefix for the item labels (required)
242 - * values: List of allowed values (required)
243 - * itemAttribs Array of attribute arrays, outer key is the value name (optional)
244 - *
245 - */
246 - public function getRadioSet( $params ) {
247 - $params['controlName'] = $this->getName() . '_' . $params['var'];
248 - $params['value'] = $this->getVar( $params['var'] );
249 - return $this->parent->getRadioSet( $params );
250 - }
251 -
252 - /**
253 - * Convenience function to set variables based on form data.
254 - * Assumes that variables containing "password" in the name are (potentially
255 - * fake) passwords.
256 - * @param $varNames Array
257 - */
258 - public function setVarsFromRequest( $varNames ) {
259 - return $this->parent->setVarsFromRequest( $varNames, $this->getName() . '_' );
260 - }
261 -
262 - /**
263 - * Determine whether an existing installation of MediaWiki is present in
264 - * the configured administrative connection. Returns true if there is
265 - * such a wiki, false if the database doesn't exist.
266 - *
267 - * Traditionally, this is done by testing for the existence of either
268 - * the revision table or the cur table.
269 - *
270 - * @return Boolean
271 - */
272 - public function needsUpgrade() {
273 - $status = $this->getConnection();
274 - if ( !$status->isOK() ) {
275 - return false;
276 - }
277 - $conn = $status->value;
278 - if ( !$conn->selectDB( $this->getVar( 'wgDBname' ) ) ) {
279 - return false;
280 - }
281 - return $conn->tableExists( 'cur' ) || $conn->tableExists( 'revision' );
282 - }
283 -
284 - /**
285 - * Get a standard install-user fieldset
286 - */
287 - public function getInstallUserBox() {
288 - return
289 - Xml::openElement( 'fieldset' ) .
290 - Xml::element( 'legend', array(), wfMsg( 'config-db-install-account' ) ) .
291 - $this->getTextBox( '_InstallUser', 'config-db-username' ) .
292 - $this->getPasswordBox( '_InstallPassword', 'config-db-password' ) .
293 - $this->parent->getHelpBox( 'config-db-install-help' ) .
294 - Xml::closeElement( 'fieldset' );
295 - }
296 -
297 - /**
298 - * Submit a standard install user fieldset
299 - */
300 - public function submitInstallUserBox() {
301 - $this->setVarsFromRequest( array( '_InstallUser', '_InstallPassword' ) );
302 - return Status::newGood();
303 - }
304 -
305 - /**
306 - * Get a standard web-user fieldset
307 - * @param $noCreateMsg String: Message to display instead of the creation checkbox.
308 - * Set this to false to show a creation checkbox.
309 - */
310 - public function getWebUserBox( $noCreateMsg = false ) {
311 - $name = $this->getName();
312 - $s = Xml::openElement( 'fieldset' ) .
313 - Xml::element( 'legend', array(), wfMsg( 'config-db-web-account' ) ) .
314 - $this->getCheckBox(
315 - '_SameAccount', 'config-db-web-account-same',
316 - array( 'class' => 'hideShowRadio', 'rel' => 'dbOtherAccount' )
317 - ) .
318 - Xml::openElement( 'div', array( 'id' => 'dbOtherAccount', 'style' => 'display: none;' ) ) .
319 - $this->getTextBox( 'wgDBuser', 'config-db-username' ) .
320 - $this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) .
321 - $this->parent->getHelpBox( 'config-db-web-help' );
322 - if ( $noCreateMsg ) {
323 - $s .= $this->parent->getWarningBox( wfMsgNoTrans( $noCreateMsg ) );
324 - } else {
325 - $s .= $this->getCheckBox( '_CreateDBAccount', 'config-db-web-create' );
326 - }
327 - $s .= Xml::closeElement( 'div' ) . Xml::closeElement( 'fieldset' );
328 - return $s;
329 - }
330 -
331 - /**
332 - * Submit the form from getWebUserBox().
333 - * @return Status
334 - */
335 - public function submitWebUserBox() {
336 - $this->setVarsFromRequest( array( 'wgDBuser', 'wgDBpassword',
337 - '_SameAccount', '_CreateDBAccount' ) );
338 - if ( $this->getVar( '_SameAccount' ) ) {
339 - $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
340 - $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
341 - }
342 - return Status::newGood();
343 - }
344 -
345 - /**
346 - * Common function for databases that don't understand the MySQLish syntax of interwiki.sql
347 - */
348 - public function populateInterwikiTable() {
349 - $status = $this->getConnection();
350 - if ( !$status->isOK() ) {
351 - return $status;
352 - }
353 - $this->db->selectDB( $this->getVar( 'wgDBname' ) );
354 -
355 - if( $this->db->selectRow( 'interwiki', '*', array(), __METHOD__ ) ) {
356 - $status->warning( 'config-install-interwiki-exists' );
357 - return $status;
358 - }
359 - global $IP;
360 - $rows = file( "$IP/maintenance/interwiki.list",
361 - FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
362 - $interwikis = array();
363 - if ( !$rows ) {
364 - return Status::newFatal( 'config-install-interwiki-sql' );
365 - }
366 - foreach( $rows as $row ) {
367 - $row = preg_replace( '/^\s*([^#]*?)\s*(#.*)?$/', '\\1', $row ); // strip comments - whee
368 - if ( $row == "" ) continue;
369 - $interwikis[] = array_combine(
370 - array( 'iw_prefix', 'iw_url', 'iw_local' ),
371 - explode( '|', $row )
372 - );
373 - }
374 - $this->db->insert( 'interwiki', $interwikis, __METHOD__ );
375 - return Status::newGood();
376 - }
377 -
378 -}
\ No newline at end of file
Index: trunk/phase3/includes/installer/DatabaseInstaller.php
@@ -0,0 +1,377 @@
 2+<?php
 3+
 4+/**
 5+ * Base class for DBMS-specific installation helper classes.
 6+ */
 7+abstract class DatabaseInstaller {
 8+
 9+ /** The Installer object */
 10+ public $parent;
 11+
 12+ /* Database connection */
 13+ public $db;
 14+
 15+ /** Internal variables for installation */
 16+ protected $internalDefaults = array();
 17+
 18+ /** Array of MW configuration globals this class uses */
 19+ protected $globalNames = array();
 20+
 21+ /**
 22+ * Return the internal name, e.g. 'mysql', or 'sqlite'.
 23+ */
 24+ public abstract function getName();
 25+
 26+ /**
 27+ * @return true if the client library is compiled in.
 28+ */
 29+ public abstract function isCompiled();
 30+
 31+ /**
 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+ * Get HTML for a web form that configures this database. Configuration
 40+ * at this time should be the minimum needed to connect and test
 41+ * whether install or upgrade is required.
 42+ *
 43+ * If this is called, $this->parent can be assumed to be a WebInstaller
 44+ */
 45+ public abstract function getConnectForm();
 46+
 47+ /**
 48+ * Set variables based on the request array, assuming it was submitted
 49+ * via the form returned by getConnectForm(). Validate the connection
 50+ * settings by attempting to connect with them.
 51+ *
 52+ * If this is called, $this->parent can be assumed to be a WebInstaller
 53+ *
 54+ * @return Status
 55+ */
 56+ public abstract function submitConnectForm();
 57+
 58+ /**
 59+ * Get HTML for a web form that retrieves settings used for installation.
 60+ * $this->parent can be assumed to be a WebInstaller.
 61+ * If the DB type has no settings beyond those already configured with
 62+ * getConnectForm(), this should return false.
 63+ */
 64+ public abstract function getSettingsForm();
 65+
 66+ /**
 67+ * Set variables based on the request array, assuming it was submitted via
 68+ * the form return by getSettingsForm().
 69+ * @return Status
 70+ */
 71+ public abstract function submitSettingsForm();
 72+
 73+ /**
 74+ * Connect to the database using the administrative user/password currently
 75+ * defined in the session. On success, return the connection, on failure,
 76+ * return a Status object.
 77+ *
 78+ * This may be called multiple times, so the result should be cached.
 79+ */
 80+ public abstract function getConnection();
 81+
 82+ /**
 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+ * Create the database and return a Status object indicating success or
 91+ * failure.
 92+ *
 93+ * @return Status
 94+ */
 95+ public abstract function setupDatabase();
 96+
 97+ /**
 98+ * Create database tables from scratch
 99+ * @return \type Status
 100+ */
 101+ public abstract function createTables();
 102+
 103+ /**
 104+ * Perform database upgrades
 105+ * @todo make abstract
 106+ */
 107+ /*abstract*/ function doUpgrade() {
 108+ return false;
 109+ }
 110+
 111+ /**
 112+ * Return any table options to be applied to all tables that don't
 113+ * override them
 114+ * @return Array
 115+ */
 116+ public function getTableOptions() {
 117+ return array();
 118+ }
 119+
 120+ /**
 121+ * Get the DBMS-specific options for LocalSettings.php generation.
 122+ * @return String
 123+ */
 124+ public abstract function getLocalSettings();
 125+
 126+ /**
 127+ * Construct and initialise parent.
 128+ * This is typically only called from Installer::getDBInstaller()
 129+ */
 130+ public function __construct( $parent ) {
 131+ $this->parent = $parent;
 132+ }
 133+
 134+ /**
 135+ * Convenience function
 136+ * Check if a named extension is present
 137+ */
 138+ protected static function checkExtension( $name ) {
 139+ wfSuppressWarnings();
 140+ $compiled = wfDl( $name );
 141+ wfRestoreWarnings();
 142+ return $compiled;
 143+ }
 144+
 145+ /**
 146+ * Get the internationalised name for this DBMS
 147+ */
 148+ public function getReadableName() {
 149+ return wfMsg( 'config-type-' . $this->getName() );
 150+ }
 151+
 152+ /**
 153+ * Get a name=>value map of MW configuration globals that overrides
 154+ * DefaultSettings.php
 155+ */
 156+ public function getGlobalDefaults() {
 157+ return array();
 158+ }
 159+
 160+ /**
 161+ * Get a name=>value map of internal variables used during installation
 162+ */
 163+ public function getInternalDefaults() {
 164+ return $this->internalDefaults;
 165+ }
 166+
 167+ /**
 168+ * Get a variable, taking local defaults into account
 169+ */
 170+ public function getVar( $var, $default = null ) {
 171+ $defaults = $this->getGlobalDefaults();
 172+ $internal = $this->getInternalDefaults();
 173+ if ( isset( $defaults[$var] ) ) {
 174+ $default = $defaults[$var];
 175+ } elseif ( isset( $internal[$var] ) ) {
 176+ $default = $internal[$var];
 177+ }
 178+ return $this->parent->getVar( $var, $default );
 179+ }
 180+
 181+ /**
 182+ * Convenience alias for $this->parent->setVar()
 183+ */
 184+ public function setVar( $name, $value ) {
 185+ $this->parent->setVar( $name, $value );
 186+ }
 187+
 188+ /**
 189+ * Get a labelled text box to configure a local variable
 190+ */
 191+ public function getTextBox( $var, $label, $attribs = array() ) {
 192+ $name = $this->getName() . '_' . $var;
 193+ $value = $this->getVar( $var );
 194+ return $this->parent->getTextBox( array(
 195+ 'var' => $var,
 196+ 'label' => $label,
 197+ 'attribs' => $attribs,
 198+ 'controlName' => $name,
 199+ 'value' => $value
 200+ ) );
 201+ }
 202+
 203+ /**
 204+ * Get a labelled password box to configure a local variable
 205+ * Implements password hiding
 206+ */
 207+ public function getPasswordBox( $var, $label, $attribs = array() ) {
 208+ $name = $this->getName() . '_' . $var;
 209+ $value = $this->getVar( $var );
 210+ return $this->parent->getPasswordBox( array(
 211+ 'var' => $var,
 212+ 'label' => $label,
 213+ 'attribs' => $attribs,
 214+ 'controlName' => $name,
 215+ 'value' => $value
 216+ ) );
 217+ }
 218+
 219+ /**
 220+ * Get a labelled checkbox to configure a local boolean variable
 221+ */
 222+ public function getCheckBox( $var, $label, $attribs = array() ) {
 223+ $name = $this->getName() . '_' . $var;
 224+ $value = $this->getVar( $var );
 225+ return $this->parent->getCheckBox( array(
 226+ 'var' => $var,
 227+ 'label' => $label,
 228+ 'attribs' => $attribs,
 229+ 'controlName' => $name,
 230+ 'value' => $value,
 231+ ));
 232+ }
 233+
 234+ /**
 235+ * Get a set of labelled radio buttons
 236+ *
 237+ * @param $params Array:
 238+ * Parameters are:
 239+ * var: The variable to be configured (required)
 240+ * label: The message name for the label (required)
 241+ * itemLabelPrefix: The message name prefix for the item labels (required)
 242+ * values: List of allowed values (required)
 243+ * itemAttribs Array of attribute arrays, outer key is the value name (optional)
 244+ *
 245+ */
 246+ public function getRadioSet( $params ) {
 247+ $params['controlName'] = $this->getName() . '_' . $params['var'];
 248+ $params['value'] = $this->getVar( $params['var'] );
 249+ return $this->parent->getRadioSet( $params );
 250+ }
 251+
 252+ /**
 253+ * Convenience function to set variables based on form data.
 254+ * Assumes that variables containing "password" in the name are (potentially
 255+ * fake) passwords.
 256+ * @param $varNames Array
 257+ */
 258+ public function setVarsFromRequest( $varNames ) {
 259+ return $this->parent->setVarsFromRequest( $varNames, $this->getName() . '_' );
 260+ }
 261+
 262+ /**
 263+ * Determine whether an existing installation of MediaWiki is present in
 264+ * the configured administrative connection. Returns true if there is
 265+ * such a wiki, false if the database doesn't exist.
 266+ *
 267+ * Traditionally, this is done by testing for the existence of either
 268+ * the revision table or the cur table.
 269+ *
 270+ * @return Boolean
 271+ */
 272+ public function needsUpgrade() {
 273+ $status = $this->getConnection();
 274+ if ( !$status->isOK() ) {
 275+ return false;
 276+ }
 277+ $conn = $status->value;
 278+ if ( !$conn->selectDB( $this->getVar( 'wgDBname' ) ) ) {
 279+ return false;
 280+ }
 281+ return $conn->tableExists( 'cur' ) || $conn->tableExists( 'revision' );
 282+ }
 283+
 284+ /**
 285+ * Get a standard install-user fieldset
 286+ */
 287+ public function getInstallUserBox() {
 288+ return
 289+ Xml::openElement( 'fieldset' ) .
 290+ Xml::element( 'legend', array(), wfMsg( 'config-db-install-account' ) ) .
 291+ $this->getTextBox( '_InstallUser', 'config-db-username' ) .
 292+ $this->getPasswordBox( '_InstallPassword', 'config-db-password' ) .
 293+ $this->parent->getHelpBox( 'config-db-install-help' ) .
 294+ Xml::closeElement( 'fieldset' );
 295+ }
 296+
 297+ /**
 298+ * Submit a standard install user fieldset
 299+ */
 300+ public function submitInstallUserBox() {
 301+ $this->setVarsFromRequest( array( '_InstallUser', '_InstallPassword' ) );
 302+ return Status::newGood();
 303+ }
 304+
 305+ /**
 306+ * Get a standard web-user fieldset
 307+ * @param $noCreateMsg String: Message to display instead of the creation checkbox.
 308+ * Set this to false to show a creation checkbox.
 309+ */
 310+ public function getWebUserBox( $noCreateMsg = false ) {
 311+ $name = $this->getName();
 312+ $s = Xml::openElement( 'fieldset' ) .
 313+ Xml::element( 'legend', array(), wfMsg( 'config-db-web-account' ) ) .
 314+ $this->getCheckBox(
 315+ '_SameAccount', 'config-db-web-account-same',
 316+ array( 'class' => 'hideShowRadio', 'rel' => 'dbOtherAccount' )
 317+ ) .
 318+ Xml::openElement( 'div', array( 'id' => 'dbOtherAccount', 'style' => 'display: none;' ) ) .
 319+ $this->getTextBox( 'wgDBuser', 'config-db-username' ) .
 320+ $this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) .
 321+ $this->parent->getHelpBox( 'config-db-web-help' );
 322+ if ( $noCreateMsg ) {
 323+ $s .= $this->parent->getWarningBox( wfMsgNoTrans( $noCreateMsg ) );
 324+ } else {
 325+ $s .= $this->getCheckBox( '_CreateDBAccount', 'config-db-web-create' );
 326+ }
 327+ $s .= Xml::closeElement( 'div' ) . Xml::closeElement( 'fieldset' );
 328+ return $s;
 329+ }
 330+
 331+ /**
 332+ * Submit the form from getWebUserBox().
 333+ * @return Status
 334+ */
 335+ public function submitWebUserBox() {
 336+ $this->setVarsFromRequest( array( 'wgDBuser', 'wgDBpassword',
 337+ '_SameAccount', '_CreateDBAccount' ) );
 338+ if ( $this->getVar( '_SameAccount' ) ) {
 339+ $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
 340+ $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
 341+ }
 342+ return Status::newGood();
 343+ }
 344+
 345+ /**
 346+ * Common function for databases that don't understand the MySQLish syntax of interwiki.sql
 347+ */
 348+ public function populateInterwikiTable() {
 349+ $status = $this->getConnection();
 350+ if ( !$status->isOK() ) {
 351+ return $status;
 352+ }
 353+ $this->db->selectDB( $this->getVar( 'wgDBname' ) );
 354+
 355+ if( $this->db->selectRow( 'interwiki', '*', array(), __METHOD__ ) ) {
 356+ $status->warning( 'config-install-interwiki-exists' );
 357+ return $status;
 358+ }
 359+ global $IP;
 360+ $rows = file( "$IP/maintenance/interwiki.list",
 361+ FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
 362+ $interwikis = array();
 363+ if ( !$rows ) {
 364+ return Status::newFatal( 'config-install-interwiki-sql' );
 365+ }
 366+ foreach( $rows as $row ) {
 367+ $row = preg_replace( '/^\s*([^#]*?)\s*(#.*)?$/', '\\1', $row ); // strip comments - whee
 368+ if ( $row == "" ) continue;
 369+ $interwikis[] = array_combine(
 370+ array( 'iw_prefix', 'iw_url', 'iw_local' ),
 371+ explode( '|', $row )
 372+ );
 373+ }
 374+ $this->db->insert( 'interwiki', $interwikis, __METHOD__ );
 375+ return Status::newGood();
 376+ }
 377+
 378+}
\ No newline at end of file
Property changes on: trunk/phase3/includes/installer/DatabaseInstaller.php
___________________________________________________________________
Added: svn:eol-style
1379 + native

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r69589Renamed InstallerDBType to DatabaseInstallerjeroendedauw09:30, 20 July 2010

Status & tagging log