r65673 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65672‎ | r65673 | r65674 >
Date:22:00, 29 April 2010
Author:platonides
Status:ok
Tags:
Comment:
MFT r65672
Modified paths:
  • /branches/REL1_16/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_16/phase3/config/Installer.php (modified) (history)
  • /branches/REL1_16/phase3/includes/db/Database.php (modified) (history)
  • /branches/REL1_16/phase3/includes/db/DatabaseIbm_db2.php (modified) (history)
  • /branches/REL1_16/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /branches/REL1_16/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /branches/REL1_16/phase3/includes/db/DatabaseSqlite.php (modified) (history)

Diff [purge]

Index: branches/REL1_16/phase3/includes/db/DatabaseOracle.php
@@ -978,14 +978,19 @@
979979 function setup_database() {
980980 global $wgVersion, $wgDBmwschema, $wgDBts2schema, $wgDBport, $wgDBuser;
981981
982 - echo "<li>Creating DB objects</li>\n";
983982 $res = $this->sourceFile( "../maintenance/ora/tables.sql" );
 983+ if ($res === true) {
 984+ print " done.</li>\n";
 985+ } else {
 986+ print " <b>FAILED</b></li>\n";
 987+ dieout( htmlspecialchars( $res ) );
 988+ }
984989
985990 // Avoid the non-standard "REPLACE INTO" syntax
986 - echo "<li>Populating table interwiki</li>\n";
 991+ echo "<li>Populating interwiki table</li>\n";
987992 $f = fopen( "../maintenance/interwiki.sql", 'r' );
988993 if ( $f == false ) {
989 - dieout( "<li>Could not find the interwiki.sql file</li>" );
 994+ dieout( "Could not find the interwiki.sql file" );
990995 }
991996
992997 // do it like the postgres :D
Index: branches/REL1_16/phase3/includes/db/DatabasePostgres.php
@@ -1311,11 +1311,17 @@
13121312 if (!$res) {
13131313 print "<b>FAILED</b>. Make sure that the user \"" . htmlspecialchars( $wgDBuser ) .
13141314 "\" can write to the schema \"" . htmlspecialchars( $wgDBmwschema ) . "\"</li>\n";
1315 - dieout("</ul>");
 1315+ dieout(""); # Will close the main list <ul> and finish the page.
13161316 }
13171317 $this->doQuery("DROP TABLE $safeschema.$ctest");
13181318
13191319 $res = $this->sourceFile( "../maintenance/postgres/tables.sql" );
 1320+ if ($res === true) {
 1321+ print " done.</li>\n";
 1322+ } else {
 1323+ print " <b>FAILED</b></li>\n";
 1324+ dieout( htmlspecialchars( $res ) );
 1325+ }
13201326
13211327 ## Update version information
13221328 $mwv = $this->addQuotes($wgVersion);
@@ -1333,10 +1339,13 @@
13341340 "WHERE type = 'Creation'";
13351341 $this->query($SQL);
13361342
 1343+ echo "<li>Populating interwiki table... ";
 1344+
13371345 ## Avoid the non-standard "REPLACE INTO" syntax
13381346 $f = fopen( "../maintenance/interwiki.sql", 'r' );
13391347 if ($f == false ) {
1340 - dieout( "<li>Could not find the interwiki.sql file");
 1348+ print "<b>FAILED</b></li>";
 1349+ dieout( "Could not find the interwiki.sql file" );
13411350 }
13421351 ## We simply assume it is already empty as we have just created it
13431352 $SQL = "INSERT INTO interwiki(iw_prefix,iw_url,iw_local) VALUES ";
@@ -1348,7 +1357,7 @@
13491358 }
13501359 $this->query("$SQL $matches[1],$matches[2])");
13511360 }
1352 - print " (table interwiki successfully populated)...\n";
 1361+ print " successfully populated.</li>\n";
13531362
13541363 $this->doQuery("COMMIT");
13551364 }
Index: branches/REL1_16/phase3/includes/db/DatabaseIbm_db2.php
@@ -746,6 +746,11 @@
747747 $this->begin();
748748
749749 $res = $this->sourceFile( "../maintenance/ibm_db2/tables.sql" );
 750+ if ($res !== true) {
 751+ print " <b>FAILED</b>: " . htmlspecialchars( $res ) . "</li>";
 752+ } else {
 753+ print " done</li>";
 754+ }
750755 $res = null;
751756
752757 // TODO: update mediawiki_version table
Index: branches/REL1_16/phase3/includes/db/Database.php
@@ -2165,9 +2165,23 @@
21662166 function sourceFile( $filename, $lineCallback = false, $resultCallback = false ) {
21672167 $fp = fopen( $filename, 'r' );
21682168 if ( false === $fp ) {
2169 - throw new MWException( "Could not open \"{$filename}\".\n" );
 2169+ if (!defined("MEDIAWIKI_INSTALL"))
 2170+ throw new MWException( "Could not open \"{$filename}\".\n" );
 2171+ else
 2172+ return "Could not open \"{$filename}\".\n";
21702173 }
2171 - $error = $this->sourceStream( $fp, $lineCallback, $resultCallback );
 2174+ try {
 2175+ $error = $this->sourceStream( $fp, $lineCallback, $resultCallback );
 2176+ }
 2177+ catch( MWException $e ) {
 2178+ if ( defined("MEDIAWIKI_INSTALL") ) {
 2179+ $error = $e->getMessage();
 2180+ } else {
 2181+ fclose( $fp );
 2182+ throw $e;
 2183+ }
 2184+ }
 2185+
21722186 fclose( $fp );
21732187 return $error;
21742188 }
Index: branches/REL1_16/phase3/includes/db/DatabaseSqlite.php
@@ -487,13 +487,17 @@
488488 # Process common MySQL/SQLite table definitions
489489 $err = $this->sourceFile( "$IP/maintenance/tables.sql" );
490490 if ( $err !== true ) {
491 - $this->reportQueryError( $err, 0, $sql, __FUNCTION__ );
492 - exit( 1 );
 491+ echo " <b>FAILED</b></li>";
 492+ dieout( htmlspecialchars( $err ) );
493493 }
 494+ echo " done.</li>";
494495
495496 # Use DatabasePostgres's code to populate interwiki from MySQL template
496497 $f = fopen( "$IP/maintenance/interwiki.sql", 'r' );
497 - if ( $f == false ) dieout( "<li>Could not find the interwiki.sql file" );
 498+ if ( $f == false ) {
 499+ dieout( "Could not find the interwiki.sql file." );
 500+ }
 501+
498502 $sql = "INSERT INTO interwiki(iw_prefix,iw_url,iw_local) VALUES ";
499503 while ( !feof( $f ) ) {
500504 $line = fgets( $f, 1024 );
Index: branches/REL1_16/phase3/config/Installer.php
@@ -1020,7 +1020,8 @@
10211021 if ($wgDatabase->isOpen()) {
10221022 $wgDBOracleDefTS = $conf->DBdefTS_ora;
10231023 $wgDBOracleTempTS = $conf->DBtempTS_ora;
1024 - $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
 1024+ $res = $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
 1025+ if ($res !== true) dieout($res);
10251026 } else {
10261027 echo "<li>Invalid database superuser, please supply a valid superuser account.</li>";
10271028 echo "<li>ERR: ".print_r(oci_error(), true)."</li>";
@@ -1197,7 +1198,8 @@
11981199 print " <b class='error'>If the next step fails, see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'>http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b>";
11991200 }
12001201 print "</li>\n";
1201 - $wgDatabase->sourceFile( "../maintenance/users.sql" );
 1202+ $res = $wgDatabase->sourceFile( "../maintenance/users.sql" );
 1203+ if ($res !== true) dieout($res);
12021204 }
12031205 }
12041206 }
@@ -1232,8 +1234,17 @@
12331235 # FIXME: Check for errors
12341236 print "<li>Creating tables...";
12351237 if ($conf->DBtype == 'mysql') {
1236 - $wgDatabase->sourceFile( "../maintenance/tables.sql" );
1237 - $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
 1238+ $res = $wgDatabase->sourceFile( "../maintenance/tables.sql" );
 1239+ if ($res === true) {
 1240+ print " done.</li>\n<li>Populating interwiki table... \n";
 1241+ $res = $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
 1242+ }
 1243+ if ($res === true) {
 1244+ print " done.</li>\n";
 1245+ } else {
 1246+ print " <b>FAILED</b></li>\n";
 1247+ dieout( htmlspecialchars( $res ) );
 1248+ }
12381249 } elseif (is_callable(array($wgDatabase, 'setup_database'))) {
12391250 $wgDatabase->setup_database();
12401251 }
@@ -1242,9 +1253,7 @@
12431254 continue;
12441255 }
12451256
1246 - print " done.</li>\n";
12471257
1248 -
12491258 if ( $conf->DBtype == 'ibm_db2' ) {
12501259 // Now that table creation is done, make sure everything is committed
12511260 // Do this before doing inserts through API
@@ -1284,8 +1293,13 @@
12851294 } else {
12861295 # Yes, so run the grants
12871296 echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
1288 - $wgDatabase->sourceFile( "../maintenance/users.sql" );
1289 - echo( "success.</li>\n" );
 1297+ $res = $wgDatabase->sourceFile( "../maintenance/users.sql" );
 1298+ if ( $res === true ) {
 1299+ echo( " success.</li>\n" );
 1300+ } else {
 1301+ echo( " <b>FAILED</b>.</li>\n" );
 1302+ dieout( $res );
 1303+ }
12901304 }
12911305 }
12921306
Index: branches/REL1_16/phase3/RELEASE-NOTES
@@ -55,6 +55,7 @@
5656 in page views and previews when the language converter is enabled.
5757 * (bug 23148) Fixed a local path disclosure vulnerability in ImageMagick image
5858 scaling, which was introduced in 1.16 beta 1.
 59+* Improved error checking on installer.
5960
6061 === Changes since 1.16 beta 1 ===
6162

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r65672Actually check sourceFile for failure, showing the error message in the install....platonides21:49, 29 April 2010

Status & tagging log