From 8e42a563d04f432eab1a8764e8a356479b649399 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Mon, 14 May 2007 22:26:25 +0000 Subject: [PATCH] Wrap MySQL specific character set detection section in MySQL-only if loop. --- config/index.php | 75 +++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/config/index.php b/config/index.php index 6ed2b40907..db92c308b1 100644 --- a/config/index.php +++ b/config/index.php @@ -839,45 +839,48 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) { print "
  • There are already MediaWiki tables in this database. Checking if updates are needed...
  • \n"; - # Determine existing default character set - if ( $wgDatabase->tableExists( "revision" ) ) { - $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' ); - $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" ); - $row = $wgDatabase->fetchObject( $res ); - if ( !$row ) { - echo "
  • SHOW TABLE STATUS query failed!
  • \n"; - $existingSchema = false; - } elseif ( preg_match( '/^latin1/', $row->Collation ) ) { - $existingSchema = 'mysql4'; - } elseif ( preg_match( '/^utf8/', $row->Collation ) ) { - $existingSchema = 'mysql5'; - } elseif ( preg_match( '/^binary/', $row->Collation ) ) { - $existingSchema = 'mysql5-binary'; - } else { - $existingSchema = false; - echo "
  • Warning: Unrecognised existing collation
  • \n"; - } - if ( $existingSchema && $existingSchema != $conf->DBschema ) { - print "
  • Warning: you requested the {$conf->DBschema} schema, " . - "but the existing database has the $existingSchema schema. This upgrade script ". - "can't convert it, so it will remain $existingSchema.
  • \n"; - $conf->setSchema( $existingSchema ); + if ( $conf->DBtype == 'mysql') { + + # Determine existing default character set + if ( $wgDatabase->tableExists( "revision" ) ) { + $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' ); + $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" ); + $row = $wgDatabase->fetchObject( $res ); + if ( !$row ) { + echo "
  • SHOW TABLE STATUS query failed!
  • \n"; + $existingSchema = false; + } elseif ( preg_match( '/^latin1/', $row->Collation ) ) { + $existingSchema = 'mysql4'; + } elseif ( preg_match( '/^utf8/', $row->Collation ) ) { + $existingSchema = 'mysql5'; + } elseif ( preg_match( '/^binary/', $row->Collation ) ) { + $existingSchema = 'mysql5-binary'; + } else { + $existingSchema = false; + echo "
  • Warning: Unrecognised existing collation
  • \n"; + } + if ( $existingSchema && $existingSchema != $conf->DBschema ) { + print "
  • Warning: you requested the {$conf->DBschema} schema, " . + "but the existing database has the $existingSchema schema. This upgrade script ". + "can't convert it, so it will remain $existingSchema.
  • \n"; + $conf->setSchema( $existingSchema ); + } } - } - # Create user if required (todo: other databases) - if ( $conf->Root && $conf->DBtype == 'mysql') { - $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); - if ( $conn->isOpen() ) { - print "
  • DB user account ok
  • \n"; - $conn->close(); - } else { - print "
  • Granting user permissions..."; - if( $mysqlOldClient && $mysqlNewAuth ) { - print " If the next step fails, see http://dev.mysql.com/doc/mysql/en/old-client.html for help."; + # Create user if required (todo: other databases) + if ( $conf->Root ) { + $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); + if ( $conn->isOpen() ) { + print "
  • DB user account ok
  • \n"; + $conn->close(); + } else { + print "
  • Granting user permissions..."; + if( $mysqlOldClient && $mysqlNewAuth ) { + print " If the next step fails, see http://dev.mysql.com/doc/mysql/en/old-client.html for help."; + } + print "
  • \n"; + dbsource( "../maintenance/users.sql", $wgDatabase ); } - print "\n"; - dbsource( "../maintenance/users.sql", $wgDatabase ); } } print "
    \n";
    -- 
    2.20.1