if ($wgDatabase->isOpen()) {
$wgDBOracleDefTS = $conf->DBdefTS_ora;
$wgDBOracleTempTS = $conf->DBtempTS_ora;
- $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
+ $res = $wgDatabase->sourceFile( "../maintenance/ora/user.sql" );
+ if ($res !== true) dieout($res);
} else {
echo "<li>Invalid database superuser, please supply a valid superuser account.</li>";
echo "<li>ERR: ".print_r(oci_error(), true)."</li>";
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>";
}
print "</li>\n";
- $wgDatabase->sourceFile( "../maintenance/users.sql" );
+ $res = $wgDatabase->sourceFile( "../maintenance/users.sql" );
+ if ($res !== true) dieout($res);
}
}
}
# FIXME: Check for errors
print "<li>Creating tables...";
if ($conf->DBtype == 'mysql') {
- $wgDatabase->sourceFile( "../maintenance/tables.sql" );
- $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
+ $res = $wgDatabase->sourceFile( "../maintenance/tables.sql" );
+ if ($res === true) {
+ print " done.</li>\n<li>Populating interwiki table... \n";
+ $res = $wgDatabase->sourceFile( "../maintenance/interwiki.sql" );
+ }
+ if ($res === true) {
+ print " done.</li>\n";
+ } else {
+ print " <b>FAILED</b></li>\n";
+ dieout( htmlspecialchars( $res ) );
+ }
} elseif (is_callable(array($wgDatabase, 'setup_database'))) {
$wgDatabase->setup_database();
}
continue;
}
- print " done.</li>\n";
-
if ( $conf->DBtype == 'ibm_db2' ) {
// Now that table creation is done, make sure everything is committed
} else {
# Yes, so run the grants
echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) );
- $wgDatabase->sourceFile( "../maintenance/users.sql" );
- echo( "success.</li>\n" );
+ $res = $wgDatabase->sourceFile( "../maintenance/users.sql" );
+ if ( $res === true ) {
+ echo( " success.</li>\n" );
+ } else {
+ echo( " <b>FAILED</b>.</li>\n" );
+ dieout( $res );
+ }
}
}
function sourceFile( $filename, $lineCallback = false, $resultCallback = false ) {
$fp = fopen( $filename, 'r' );
if ( false === $fp ) {
- throw new MWException( "Could not open \"{$filename}\".\n" );
+ if (!defined("MEDIAWIKI_INSTALL"))
+ throw new MWException( "Could not open \"{$filename}\".\n" );
+ else
+ return "Could not open \"{$filename}\".\n";
+ }
+ try {
+ $error = $this->sourceStream( $fp, $lineCallback, $resultCallback );
+ }
+ catch( MWException $e ) {
+ if ( defined("MEDIAWIKI_INSTALL") ) {
+ $error = $e->getMessage();
+ } else {
+ fclose( $fp );
+ throw $e;
+ }
}
- $error = $this->sourceStream( $fp, $lineCallback, $resultCallback );
+
fclose( $fp );
return $error;
}
$this->begin();
$res = $this->sourceFile( "../maintenance/ibm_db2/tables.sql" );
+ if ($res !== true) {
+ print " <b>FAILED</b>: " . htmlspecialchars( $res ) . "</li>";
+ } else {
+ print " done</li>";
+ }
$res = null;
// TODO: populate interwiki links
function setup_database() {
global $wgVersion, $wgDBmwschema, $wgDBts2schema, $wgDBport, $wgDBuser;
- echo "<li>Creating DB objects</li>\n";
$res = $this->sourceFile( "../maintenance/ora/tables.sql" );
+ if ($res === true) {
+ print " done.</li>\n";
+ } else {
+ print " <b>FAILED</b></li>\n";
+ dieout( htmlspecialchars( $res ) );
+ }
// Avoid the non-standard "REPLACE INTO" syntax
- echo "<li>Populating table interwiki</li>\n";
+ echo "<li>Populating interwiki table</li>\n";
$f = fopen( "../maintenance/interwiki.sql", 'r' );
if ( $f == false ) {
- dieout( "<li>Could not find the interwiki.sql file</li>" );
+ dieout( "Could not find the interwiki.sql file" );
}
// do it like the postgres :D
if (!$res) {
print "<b>FAILED</b>. Make sure that the user \"" . htmlspecialchars( $wgDBuser ) .
"\" can write to the schema \"" . htmlspecialchars( $wgDBmwschema ) . "\"</li>\n";
- dieout("</ul>");
+ dieout(""); # Will close the main list <ul> and finish the page.
}
$this->doQuery("DROP TABLE $safeschema.$ctest");
$res = $this->sourceFile( "../maintenance/postgres/tables.sql" );
+ if ($res === true) {
+ print " done.</li>\n";
+ } else {
+ print " <b>FAILED</b></li>\n";
+ dieout( htmlspecialchars( $res ) );
+ }
## Update version information
$mwv = $this->addQuotes($wgVersion);
$dbn = $this->addQuotes($this->mDBname);
$ctype = $this->addQuotes( pg_fetch_result($this->doQuery("SHOW lc_ctype"),0,0) );
+ echo "<li>Populating interwiki table... ";
## Avoid the non-standard "REPLACE INTO" syntax
$f = fopen( "../maintenance/interwiki.sql", 'r' );
if ($f == false ) {
- dieout( "<li>Could not find the interwiki.sql file");
+ print "<b>FAILED</b></li>";
+ dieout( "Could not find the interwiki.sql file" );
}
## We simply assume it is already empty as we have just created it
$SQL = "INSERT INTO interwiki(iw_prefix,iw_url,iw_local) VALUES ";
}
$this->query("$SQL $matches[1],$matches[2])");
}
- print " (table interwiki successfully populated)...\n";
+ print " successfully populated.</li>\n";
$this->doQuery("COMMIT");
}
# Process common MySQL/SQLite table definitions
$err = $this->sourceFile( "$IP/maintenance/tables.sql" );
if ( $err !== true ) {
- $this->reportQueryError( $err, 0, $sql, __FUNCTION__ );
- exit( 1 );
+ echo " <b>FAILED</b></li>";
+ dieout( htmlspecialchars( $err ) );
}
+ echo " done.</li>";
# Use DatabasePostgres's code to populate interwiki from MySQL template
$f = fopen( "$IP/maintenance/interwiki.sql", 'r' );
- if ( $f == false ) dieout( "<li>Could not find the interwiki.sql file" );
+ if ( $f == false ) {
+ dieout( "Could not find the interwiki.sql file." );
+ }
+
$sql = "INSERT INTO interwiki(iw_prefix,iw_url,iw_local) VALUES ";
while ( !feof( $f ) ) {
$line = fgets( $f, 1024 );