From: Tim Starling Date: Sun, 22 Apr 2007 14:04:06 +0000 (+0000) Subject: * Removed mysql5 SQL files, obviously we're collectively incapable of keeping them... X-Git-Tag: 1.31.0-rc.0~53289 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=0a93752af67fe6d31ba279c11e376ce5c145a4c3;p=lhc%2Fweb%2Fwiklou.git * Removed mysql5 SQL files, obviously we're collectively incapable of keeping them up to date. They were littered with errors. The only deliberate difference appears to be the table character set, which can be adjusted programatically using a variable. * Added table option variable to the SQL patch files, so now upgrading a non-standard schema won't leave your database horribly corrupted. * Added sql.php, for sourcing SQL files with MediaWiki variable substitution. * Disable MySQL's strict mode at session start for MySQL 4.1+, to avoid the various problems that occur when it is on. --- diff --git a/config/index.php b/config/index.php index b392a6d7c2..e1ec6acaed 100644 --- a/config/index.php +++ b/config/index.php @@ -226,6 +226,26 @@ class ConfigData { function getSitename() { return $this->getEncoded( $this->Sitename ); } function getSysopName() { return $this->getEncoded( $this->SysopName ); } function getSysopPass() { return $this->getEncoded( $this->SysopPass ); } + + function setSchema( $schema ) { + $this->DBschema = $schema; + switch ( $this->DBschema ) { + case 'mysql5': + $this->DBTableOptions = 'ENGINE=InnoDB, DEFAULT CHARSET=utf8'; + $this->DBmysql5 = 'true'; + break; + case 'mysql5-binary': + $this->DBTableOptions = 'ENGINE=InnoDB, DEFAULT CHARSET=binary'; + $this->DBmysql5 = 'true'; + break; + default: + $this->DBTableOptions = 'TYPE=InnoDB'; + $this->DBmysql5 = 'false'; + } + # Set the global for use during install + global $wgDBTableOptions; + $wgDBTableOptions = $this->DBTableOptions; + } } ?> @@ -522,10 +542,7 @@ print "
  • Environment check ## MySQL specific: $conf->DBprefix = importPost( "DBprefix" ); - $conf->DBschema = importPost( "DBschema", "mysql4" ); - $conf->DBmysql5 = ($conf->DBschema == "mysql5" || - $conf->DBschema == "mysql5-binary") - ? "true" : "false"; + $conf->setSchema( importPost( "DBschema", "mysql4" ) ); $conf->LanguageCode = importPost( "LanguageCode", "en" ); ## Postgres specific: @@ -813,6 +830,32 @@ 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 ); + } + } + # Create user if required (todo: other databases) if ( $conf->Root && $conf->DBtype == 'mysql') { $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); @@ -828,33 +871,18 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { dbsource( "../maintenance/users.sql", $wgDatabase ); } } - print "
    \n";
    +			print "
    \n";
     			chdir( ".." );
     			flush();
     			do_all_updates();
     			chdir( "config" );
     			print "
    \n"; - print "
  • Finished update checks.
  • \n"; + print "