r23236 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23235‎ | r23236 | r23237 >
Date:18:17, 22 June 2007
Author:tstarling
Status:old
Tags:
Comment:
* Added option to install with MyISAM
* Select MySQL by default if both drivers are available
* Use a frameset for the DB-specific box, instead of a garish orange background
* A big font and an <hr> for the final success message, since people sometimes forget to read it
Modified paths:
  • /trunk/phase3/config/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/config/index.php
@@ -158,7 +158,10 @@
159159 font-weight: bold;
160160 font-size: 110%;
161161 color: green;
162 - }
 162+ }
 163+ .success-box {
 164+ font-size: 130%;
 165+ }
163166
164167 </style>
165168 <script type="text/javascript">
@@ -240,21 +243,26 @@
241244 function getSysopName() { return $this->getEncoded( $this->SysopName ); }
242245 function getSysopPass() { return $this->getEncoded( $this->SysopPass ); }
243246
244 - function setSchema( $schema ) {
 247+ function setSchema( $schema, $engine ) {
245248 $this->DBschema = $schema;
 249+ if ( !preg_match( '/^\w*$/', $engine ) ){
 250+ $engine = 'InnoDB';
 251+ }
246252 switch ( $this->DBschema ) {
247253 case 'mysql5':
248 - $this->DBTableOptions = 'ENGINE=InnoDB, DEFAULT CHARSET=utf8';
 254+ $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=utf8";
249255 $this->DBmysql5 = 'true';
250256 break;
251257 case 'mysql5-binary':
252 - $this->DBTableOptions = 'ENGINE=InnoDB, DEFAULT CHARSET=binary';
 258+ $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=binary";
253259 $this->DBmysql5 = 'true';
254260 break;
255261 default:
256 - $this->DBTableOptions = 'TYPE=InnoDB';
 262+ $this->DBTableOptions = "TYPE=$engine";
257263 $this->DBmysql5 = 'false';
258264 }
 265+ $this->DBengine = $engine;
 266+
259267 # Set the global for use during install
260268 global $wgDBTableOptions;
261269 $wgDBTableOptions = $this->DBTableOptions;
@@ -309,15 +317,16 @@
310318 }
311319
312320 print "<li>Found database drivers for:";
 321+$DefaultDBtype = '';
313322 foreach (array_keys($ourdb) AS $db) {
314323 if ($ourdb[$db]['havedriver']) {
315 - $DefaultDBtype = $db;
 324+ if ( $DefaultDBtype == '' ) {
 325+ $DefaultDBtype = $db;
 326+ }
316327 print " ".$ourdb[$db]['fullname'];
317328 }
318329 }
319330 print "</li>\n";
320 -if (count($phpdatabases) != 1)
321 - $DefaultDBtype = '';
322331
323332 if( ini_get( "register_globals" ) ) {
324333 ?>
@@ -567,7 +576,9 @@
568577
569578 ## MySQL specific:
570579 $conf->DBprefix = importPost( "DBprefix" );
571 - $conf->setSchema( importPost( "DBschema", "mysql4" ) );
 580+ $conf->setSchema(
 581+ importPost( "DBschema", "mysql4" ),
 582+ importPost( "DBengine", "InnoDB" ) );
572583
573584 ## Postgres specific:
574585 $conf->DBport = importPost( "DBport", "5432" );
@@ -891,7 +902,6 @@
892903 print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
893904
894905 if ( $conf->DBtype == 'mysql') {
895 -
896906 # Determine existing default character set
897907 if ( $wgDatabase->tableExists( "revision" ) ) {
898908 $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' );
@@ -900,22 +910,36 @@
901911 if ( !$row ) {
902912 echo "<li>SHOW TABLE STATUS query failed!</li>\n";
903913 $existingSchema = false;
904 - } elseif ( preg_match( '/^latin1/', $row->Collation ) ) {
905 - $existingSchema = 'mysql4';
906 - } elseif ( preg_match( '/^utf8/', $row->Collation ) ) {
907 - $existingSchema = 'mysql5';
908 - } elseif ( preg_match( '/^binary/', $row->Collation ) ) {
909 - $existingSchema = 'mysql5-binary';
 914+ $existingEngine = false;
910915 } else {
911 - $existingSchema = false;
912 - echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
 916+ if ( preg_match( '/^latin1/', $row->Collation ) ) {
 917+ $existingSchema = 'mysql4';
 918+ } elseif ( preg_match( '/^utf8/', $row->Collation ) ) {
 919+ $existingSchema = 'mysql5';
 920+ } elseif ( preg_match( '/^binary/', $row->Collation ) ) {
 921+ $existingSchema = 'mysql5-binary';
 922+ } else {
 923+ $existingSchema = false;
 924+ echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n";
 925+ }
 926+ if ( isset( $row->Engine ) ) {
 927+ $existingEngine = $row->Engine;
 928+ } else {
 929+ $existingEngine = $row->Type;
 930+ }
913931 }
914932 if ( $existingSchema && $existingSchema != $conf->DBschema ) {
915933 print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " .
916934 "but the existing database has the $existingSchema schema. This upgrade script ".
917935 "can't convert it, so it will remain $existingSchema.</li>\n";
918 - $conf->setSchema( $existingSchema );
 936+ $conf->setSchema( $existingSchema, $conf->DBengine );
919937 }
 938+ if ( $existingEngine && $existingEngine != $conf->DBengine ) {
 939+ print "<li><strong>Warning:</strong> you requested the {$conf->DBengine} storage " .
 940+ "engine, but the existing database uses the $existingEngine engine. This upgrade " .
 941+ "script can't convert it, so it will remain $existingEngine.</li>\n";
 942+ $conf->setSchema( $conf->DBschema, $existingEngine );
 943+ }
920944 }
921945
922946 # Create user if required
@@ -942,6 +966,24 @@
943967 print "</pre>\n";
944968 print "<ul><li>Finished update checks.</li>\n";
945969 } else {
 970+ # Determine available storage engines if possible
 971+ if ( $conf->DBtype == 'mysql' && version_compare( $myver, "4.1.2", "ge" ) ) {
 972+ $res = $wgDatabase->query( 'SHOW ENGINES' );
 973+ $found = false;
 974+ while ( $row = $wgDatabase->fetchObject( $res ) ) {
 975+ if ( $row->Engine == $conf->DBengine ) {
 976+ $found = true;
 977+ break;
 978+ }
 979+ }
 980+ $wgDatabase->freeResult( $res );
 981+ if ( !$found && $conf->DBengine != 'MyISAM' ) {
 982+ echo "<li><strong>Warning:</strong> {$conf->DBengine} storage engine not available, " .
 983+ "using MyISAM instead</li>\n";
 984+ $conf->setSchema( $conf->DBschema, 'MyISAM' );
 985+ }
 986+ }
 987+
946988 # FIXME: Check for errors
947989 print "<li>Creating tables...";
948990 if ($conf->DBtype == 'mysql') {
@@ -1031,13 +1073,13 @@
10321074 }
10331075 if(fwrite( $f, $localSettings ) ) {
10341076 fclose( $f );
 1077+ print "</li></ul><hr/>\n";
10351078 writeSuccessMessage();
10361079 } else {
10371080 fclose( $f );
10381081 die("<p class='error'>An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.</p>\n");
1039 -
 1082+ print "</li></ul>\n";
10401083 }
1041 - print "</li>\n";
10421084
10431085 } while( false );
10441086 }
@@ -1309,9 +1351,21 @@
13101352 <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p>
13111353 </div>
13121354
1313 - <div class="config-input"><label class="column">Database charset</label>
 1355+ <div class="config-input"><label class="column">Storage Engine</label>
13141356 <div>Select one:</div>
13151357 <ul class="plain">
 1358+ <li><?php aField( $conf, "DBengine", "InnoDB", "radio", "InnoDB" ); ?></li>
 1359+ <li><?php aField( $conf, "DBengine", "MyISAM", "radio", "MyISAM" ); ?></li>
 1360+ </ul>
 1361+ </div>
 1362+ <p class="config-desc">
 1363+ InnoDB is best for public web installations, since it has good concurrency
 1364+ support. MyISAM may be faster in single-user installations. MyISAM databases
 1365+ tend to get corrupted more often than InnoDB databases.
 1366+ </p>
 1367+ <div class="config-input"><label class="column">Database character set</label>
 1368+ <div>Select one:</div>
 1369+ <ul class="plain">
13161370 <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li>
13171371 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li>
13181372 <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li>
@@ -1340,7 +1394,7 @@
13411395 so it is recommended that you create a new user. The above schemas are generally correct:
13421396 only change them if you are sure you need to.</p>
13431397 </div>
1344 - </div>
 1398+ </fieldset>
13451399
13461400 <div class="config-input" style="padding:2em 0 3em">
13471401 <label class='column'>&nbsp;</label>
@@ -1366,6 +1420,7 @@
13671421 function writeSuccessMessage() {
13681422 if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) {
13691423 echo <<<EOT
 1424+<div class="success-box">
13701425 <p>Installation successful!</p>
13711426 <p>To complete the installation, please do the following:
13721427 <ol>
@@ -1378,15 +1433,18 @@
13791434 remotely. LocalSettings.php is currently owned by the user your webserver is running under,
13801435 which means that anyone on the same server can read your database password! Downloading
13811436 it and uploading it again will hopefully change the ownership to a user ID specific to you.</p>
 1437+</div>
13821438 EOT;
13831439 } else {
13841440 echo <<<EOT
 1441+<div class="success-box">
13851442 <p>
13861443 <span class="success-message">Installation successful!</span>
13871444 Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow
13881445 <a href="../index.php"> this link</a> to your wiki.</p>
13891446 <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to
13901447 prevent other users on the server reading passwords and altering configuration data.</p>
 1448+</div>
13911449 EOT;
13921450 }
13931451 }
@@ -1791,8 +1849,7 @@
17921850 global $ourdb;
17931851 $color = $ourdb[$db]['bgcolor'];
17941852 $full = $ourdb[$db]['fullname'];
1795 - print "<div id='$db' style='display:none; background: $color'>\n";
1796 - print "<h3>$full specific options:</h3>\n";
 1853+ print "<fieldset id='$db'><legend>$full specific options</legend>\n";
17971854 }
17981855
17991856 function printListItem( $item ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r23407Merged revisions 23203-23405 via svnmerge from...david23:00, 25 June 2007

Status & tagging log