From 72e90545454c0e014318fa3c81658e035aac58c1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 10 Jun 2009 13:00:47 +0200 Subject: applying patch to version 1.15.0 --- config/index.php | 159 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 133 insertions(+), 26 deletions(-) (limited to 'config') diff --git a/config/index.php b/config/index.php index ced8bc92..85fdb86f 100644 --- a/config/index.php +++ b/config/index.php @@ -47,11 +47,13 @@ require_once( "$IP/includes/Namespace.php" ); require_once( "$IP/includes/ProfilerStub.php" ); require_once( "$IP/includes/GlobalFunctions.php" ); require_once( "$IP/includes/Hooks.php" ); +require_once( "$IP/includes/Exception.php" ); # If we get an exception, the user needs to know # all the details $wgShowExceptionDetails = true; - +$wgShowSQLErrors = true; +wfInstallExceptionHandler(); ## Databases we support: $ourdb = array(); @@ -67,13 +69,11 @@ $ourdb['postgres']['compile'] = 'pgsql'; $ourdb['postgres']['bgcolor'] = '#aaccff'; $ourdb['postgres']['rootuser'] = 'postgres'; -/*** SQLITE DISABLED -- USE MEDIAWIKI 1.15 */ -#$ourdb['sqlite']['fullname'] = 'SQLite'; -#$ourdb['sqlite']['havedriver'] = 0; -#$ourdb['sqlite']['compile'] = 'pdo_sqlite'; -#$ourdb['sqlite']['bgcolor'] = '#b1ebb1'; -#$ourdb['sqlite']['rootuser'] = ''; -/************************************/ +$ourdb['sqlite']['fullname'] = 'SQLite'; +$ourdb['sqlite']['havedriver'] = 0; +$ourdb['sqlite']['compile'] = 'pdo_sqlite'; +$ourdb['sqlite']['bgcolor'] = '#b1ebb1'; +$ourdb['sqlite']['rootuser'] = ''; $ourdb['mssql']['fullname'] = 'MSSQL'; $ourdb['mssql']['havedriver'] = 0; @@ -81,6 +81,12 @@ $ourdb['mssql']['compile'] = 'mssql not ready'; # Change to 'mssql' after $ourdb['mssql']['bgcolor'] = '#ffc0cb'; $ourdb['mssql']['rootuser'] = 'administrator'; +$ourdb['ibm_db2']['fullname'] = 'DB2'; +$ourdb['ibm_db2']['havedriver'] = 0; +$ourdb['ibm_db2']['compile'] = 'ibm_db2'; +$ourdb['ibm_db2']['bgcolor'] = '#ffeba1'; +$ourdb['ibm_db2']['rootuser'] = 'db2admin'; + ?> @@ -621,6 +627,12 @@ print "
  • Environment check ## MSSQL specific // We need a second field so it doesn't overwrite the MySQL one $conf->DBprefix2 = importPost( "DBprefix2" ); + + ## DB2 specific: + // New variable in order to have a different default port number + $conf->DBport_db2 = importPost( "DBport_db2", "50000" ); + $conf->DBmwschema = importPost( "DBmwschema", "mediawiki" ); + $conf->DBcataloged = importPost( "DBcataloged", "cataloged" ); $conf->ShellLocale = getShellLocale( $conf->LanguageCode ); @@ -644,6 +656,8 @@ if( $conf->DBpassword != $conf->DBpassword2 ) { } if( !preg_match( '/^[A-Za-z_0-9]*$/', $conf->DBprefix ) ) { $errs["DBprefix"] = "Invalid table prefix"; +} else { + untaint( $conf->DBprefix, TC_MYSQL ); } error_reporting( E_ALL ); @@ -720,7 +734,7 @@ $conf->MCServers = importRequest( "MCServers" ); /* Test memcached servers */ if ( $conf->Shm == 'memcached' && $conf->MCServers ) { - $conf->MCServerArray = array_map( 'trim', explode( ',', $conf->MCServers ) ); + $conf->MCServerArray = wfArrayMap( 'trim', explode( ',', $conf->MCServers ) ); foreach ( $conf->MCServerArray as $server ) { $error = testMemcachedServer( $server ); if ( $error ) { @@ -792,6 +806,9 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $wgDBprefix = $conf->DBprefix2; } + ## DB2 specific: + $wgDBcataloged = $conf->DBcataloged; + $wgCommandLineMode = true; if (! defined ( 'STDERR' ) ) define( 'STDERR', fopen("php://stderr", "wb")); @@ -802,7 +819,9 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $wgTitle = Title::newFromText( "Installation script" ); error_reporting( E_ALL ); print "
  • Loading class: " . htmlspecialchars( $dbclass ) . "
  • \n"; - $dbc = new $dbclass; + if ( $conf->DBtype != 'sqlite' ) { + $dbc = new $dbclass; + } if( $conf->DBtype == 'mysql' ) { $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" ); @@ -867,12 +886,71 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { } #conn. att. if( !$ok ) { continue; } + } + else if( $conf->DBtype == 'ibm_db2' ) { + if( $useRoot ) { + $db_user = $conf->RootUser; + $db_pass = $conf->RootPW; + } else { + $db_user = $wgDBuser; + $db_pass = $wgDBpassword; + } + + echo( "
  • Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) . + "\" as \"" . htmlspecialchars( $db_user ) . "\"..." ); + $wgDatabase = $dbc->newFromParams($wgDBserver, $db_user, $db_pass, $wgDBname, 1); + if (!$wgDatabase->isOpen()) { + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "
  • \n"; + } else { + $myver = $wgDatabase->getServerVersion(); + } + if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); + } elseif ( $conf->DBtype == 'sqlite' ) { + if ("$wgSQLiteDataDir" == '') { + $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data'; + } + echo "
  • Attempting to connect to SQLite database at \"" . + htmlspecialchars( $wgSQLiteDataDir ) . "\""; + if ( !is_dir( $wgSQLiteDataDir ) ) { + if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) { + $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode ); + } else { + $ok = false; + } + if ( !$ok ) { + echo ": cannot create data directory
  • "; + $errs['SQLiteDataDir'] = 'Enter a valid data directory'; + continue; + } + } + if ( !is_writable( $wgSQLiteDataDir ) ) { + echo ": data directory not writable"; + $errs['SQLiteDataDir'] = 'Enter a writable data directory'; + continue; + } + $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite"; + if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) { + echo ": data file not writable"; + $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable"; + continue; + } + $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 ); + if (!$wgDatabase->isOpen()) { + print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "\n"; + $errs['SQLiteDataDir'] = 'Could not connect to database'; + continue; + } else { + $myver = $wgDatabase->getServerVersion(); + } + if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname); + echo "ok\n"; } else { # not mysql error_reporting( E_ALL ); $wgSuperUser = ''; ## Possible connect as a superuser - if( $useRoot && $conf->DBtype != 'sqlite' ) { + // Changed !mysql to postgres check since it seems to only apply to postgres + if( $useRoot && $conf->DBtype == 'postgres' ) { $wgDBsuperuser = $conf->RootUser; echo( "
  • Attempting to connect to database \"postgres\" as superuser \"" . htmlspecialchars( $wgDBsuperuser ) . "\"..." ); @@ -1126,6 +1204,8 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { $revid = $revision->insertOn( $wgDatabase ); $article->updateRevisionOn( $wgDatabase, $revision ); } + // Now that all database work is done, make sure everything is committed + $wgDatabase->commit(); /* Write out the config file now that all is well */ print "
  • \n"; @@ -1450,10 +1530,6 @@ if( count( $errs ) ) { -
    NOTE: SQLite only uses the Database name setting above, the user, password and root settings are ignored. @@ -1470,11 +1546,6 @@ if( count( $errs ) ) {
    - -
    Avoid exotic characters; something like mw_ is good.

    + + +
    +
    +
    Select one:
    + +
    +

    If you need to share one database between multiple wikis, or + between MediaWiki and another web application, you may specify + a different schema to avoid conflicts.

    +
    +
    @@ -1495,7 +1585,7 @@ if( count( $errs ) ) {
    -

    MediaWiki is Copyright © 2001-2008 by Magnus Manske, Brion Vibber, +

    MediaWiki is Copyright © 2001-2009 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason, Niklas Laxström, Domas Mituzas, Rob Church, Yuri Astrakhan, Aryeh Gregor, Aaron Schulz and others.

    -- cgit v1.2.3-54-g00ecf