Index: trunk/phase3/config/index.php |
— | — | @@ -158,7 +158,10 @@ |
159 | 159 | font-weight: bold; |
160 | 160 | font-size: 110%; |
161 | 161 | color: green; |
162 | | - } |
| 162 | + } |
| 163 | + .success-box { |
| 164 | + font-size: 130%; |
| 165 | + } |
163 | 166 | |
164 | 167 | </style> |
165 | 168 | <script type="text/javascript"> |
— | — | @@ -240,21 +243,26 @@ |
241 | 244 | function getSysopName() { return $this->getEncoded( $this->SysopName ); } |
242 | 245 | function getSysopPass() { return $this->getEncoded( $this->SysopPass ); } |
243 | 246 | |
244 | | - function setSchema( $schema ) { |
| 247 | + function setSchema( $schema, $engine ) { |
245 | 248 | $this->DBschema = $schema; |
| 249 | + if ( !preg_match( '/^\w*$/', $engine ) ){ |
| 250 | + $engine = 'InnoDB'; |
| 251 | + } |
246 | 252 | switch ( $this->DBschema ) { |
247 | 253 | case 'mysql5': |
248 | | - $this->DBTableOptions = 'ENGINE=InnoDB, DEFAULT CHARSET=utf8'; |
| 254 | + $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=utf8"; |
249 | 255 | $this->DBmysql5 = 'true'; |
250 | 256 | break; |
251 | 257 | case 'mysql5-binary': |
252 | | - $this->DBTableOptions = 'ENGINE=InnoDB, DEFAULT CHARSET=binary'; |
| 258 | + $this->DBTableOptions = "ENGINE=$engine, DEFAULT CHARSET=binary"; |
253 | 259 | $this->DBmysql5 = 'true'; |
254 | 260 | break; |
255 | 261 | default: |
256 | | - $this->DBTableOptions = 'TYPE=InnoDB'; |
| 262 | + $this->DBTableOptions = "TYPE=$engine"; |
257 | 263 | $this->DBmysql5 = 'false'; |
258 | 264 | } |
| 265 | + $this->DBengine = $engine; |
| 266 | + |
259 | 267 | # Set the global for use during install |
260 | 268 | global $wgDBTableOptions; |
261 | 269 | $wgDBTableOptions = $this->DBTableOptions; |
— | — | @@ -309,15 +317,16 @@ |
310 | 318 | } |
311 | 319 | |
312 | 320 | print "<li>Found database drivers for:"; |
| 321 | +$DefaultDBtype = ''; |
313 | 322 | foreach (array_keys($ourdb) AS $db) { |
314 | 323 | if ($ourdb[$db]['havedriver']) { |
315 | | - $DefaultDBtype = $db; |
| 324 | + if ( $DefaultDBtype == '' ) { |
| 325 | + $DefaultDBtype = $db; |
| 326 | + } |
316 | 327 | print " ".$ourdb[$db]['fullname']; |
317 | 328 | } |
318 | 329 | } |
319 | 330 | print "</li>\n"; |
320 | | -if (count($phpdatabases) != 1) |
321 | | - $DefaultDBtype = ''; |
322 | 331 | |
323 | 332 | if( ini_get( "register_globals" ) ) { |
324 | 333 | ?> |
— | — | @@ -567,7 +576,9 @@ |
568 | 577 | |
569 | 578 | ## MySQL specific: |
570 | 579 | $conf->DBprefix = importPost( "DBprefix" ); |
571 | | - $conf->setSchema( importPost( "DBschema", "mysql4" ) ); |
| 580 | + $conf->setSchema( |
| 581 | + importPost( "DBschema", "mysql4" ), |
| 582 | + importPost( "DBengine", "InnoDB" ) ); |
572 | 583 | |
573 | 584 | ## Postgres specific: |
574 | 585 | $conf->DBport = importPost( "DBport", "5432" ); |
— | — | @@ -891,7 +902,6 @@ |
892 | 903 | print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n"; |
893 | 904 | |
894 | 905 | if ( $conf->DBtype == 'mysql') { |
895 | | - |
896 | 906 | # Determine existing default character set |
897 | 907 | if ( $wgDatabase->tableExists( "revision" ) ) { |
898 | 908 | $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' ); |
— | — | @@ -900,22 +910,36 @@ |
901 | 911 | if ( !$row ) { |
902 | 912 | echo "<li>SHOW TABLE STATUS query failed!</li>\n"; |
903 | 913 | $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; |
910 | 915 | } 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 | + } |
913 | 931 | } |
914 | 932 | if ( $existingSchema && $existingSchema != $conf->DBschema ) { |
915 | 933 | print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " . |
916 | 934 | "but the existing database has the $existingSchema schema. This upgrade script ". |
917 | 935 | "can't convert it, so it will remain $existingSchema.</li>\n"; |
918 | | - $conf->setSchema( $existingSchema ); |
| 936 | + $conf->setSchema( $existingSchema, $conf->DBengine ); |
919 | 937 | } |
| 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 | + } |
920 | 944 | } |
921 | 945 | |
922 | 946 | # Create user if required |
— | — | @@ -942,6 +966,24 @@ |
943 | 967 | print "</pre>\n"; |
944 | 968 | print "<ul><li>Finished update checks.</li>\n"; |
945 | 969 | } 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 | + |
946 | 988 | # FIXME: Check for errors |
947 | 989 | print "<li>Creating tables..."; |
948 | 990 | if ($conf->DBtype == 'mysql') { |
— | — | @@ -1031,13 +1073,13 @@ |
1032 | 1074 | } |
1033 | 1075 | if(fwrite( $f, $localSettings ) ) { |
1034 | 1076 | fclose( $f ); |
| 1077 | + print "</li></ul><hr/>\n"; |
1035 | 1078 | writeSuccessMessage(); |
1036 | 1079 | } else { |
1037 | 1080 | fclose( $f ); |
1038 | 1081 | 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"; |
1040 | 1083 | } |
1041 | | - print "</li>\n"; |
1042 | 1084 | |
1043 | 1085 | } while( false ); |
1044 | 1086 | } |
— | — | @@ -1309,9 +1351,21 @@ |
1310 | 1352 | <p>Avoid exotic characters; something like <tt>mw_</tt> is good.</p> |
1311 | 1353 | </div> |
1312 | 1354 | |
1313 | | - <div class="config-input"><label class="column">Database charset</label> |
| 1355 | + <div class="config-input"><label class="column">Storage Engine</label> |
1314 | 1356 | <div>Select one:</div> |
1315 | 1357 | <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"> |
1316 | 1370 | <li><?php aField( $conf, "DBschema", "Backwards-compatible UTF-8", "radio", "mysql4" ); ?></li> |
1317 | 1371 | <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 UTF-8", "radio", "mysql5" ); ?></li> |
1318 | 1372 | <li><?php aField( $conf, "DBschema", "Experimental MySQL 4.1/5.0 binary", "radio", "mysql5-binary" ); ?></li> |
— | — | @@ -1340,7 +1394,7 @@ |
1341 | 1395 | so it is recommended that you create a new user. The above schemas are generally correct: |
1342 | 1396 | only change them if you are sure you need to.</p> |
1343 | 1397 | </div> |
1344 | | - </div> |
| 1398 | + </fieldset> |
1345 | 1399 | |
1346 | 1400 | <div class="config-input" style="padding:2em 0 3em"> |
1347 | 1401 | <label class='column'> </label> |
— | — | @@ -1366,6 +1420,7 @@ |
1367 | 1421 | function writeSuccessMessage() { |
1368 | 1422 | if ( ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ) { |
1369 | 1423 | echo <<<EOT |
| 1424 | +<div class="success-box"> |
1370 | 1425 | <p>Installation successful!</p> |
1371 | 1426 | <p>To complete the installation, please do the following: |
1372 | 1427 | <ol> |
— | — | @@ -1378,15 +1433,18 @@ |
1379 | 1434 | remotely. LocalSettings.php is currently owned by the user your webserver is running under, |
1380 | 1435 | which means that anyone on the same server can read your database password! Downloading |
1381 | 1436 | it and uploading it again will hopefully change the ownership to a user ID specific to you.</p> |
| 1437 | +</div> |
1382 | 1438 | EOT; |
1383 | 1439 | } else { |
1384 | 1440 | echo <<<EOT |
| 1441 | +<div class="success-box"> |
1385 | 1442 | <p> |
1386 | 1443 | <span class="success-message">Installation successful!</span> |
1387 | 1444 | Move the <tt>config/LocalSettings.php</tt> file to the parent directory, then follow |
1388 | 1445 | <a href="../index.php"> this link</a> to your wiki.</p> |
1389 | 1446 | <p>You should change file permissions for <tt>LocalSettings.php</tt> as required to |
1390 | 1447 | prevent other users on the server reading passwords and altering configuration data.</p> |
| 1448 | +</div> |
1391 | 1449 | EOT; |
1392 | 1450 | } |
1393 | 1451 | } |
— | — | @@ -1791,8 +1849,7 @@ |
1792 | 1850 | global $ourdb; |
1793 | 1851 | $color = $ourdb[$db]['bgcolor']; |
1794 | 1852 | $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"; |
1797 | 1854 | } |
1798 | 1855 | |
1799 | 1856 | function printListItem( $item ) { |