r80957 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80956‎ | r80957 | r80958 >
Date:07:37, 25 January 2011
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMysql.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/includes/db/LBFactory.php (modified) (history)
  • /trunk/phase3/includes/db/LBFactory_Single.php (added) (history)
  • /trunk/phase3/includes/installer/DatabaseInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/OracleInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/SqliteInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseMysql.php
@@ -558,6 +558,11 @@
559559 return $this->query( "DROP TABLE IF EXISTS " . $this->tableName( $tableName ), $fName );
560560 }
561561
 562+ protected function getDefaultSchemaVars() {
 563+ $vars = parent::getDefaultSchemaVars();
 564+ $vars['wgDBTableOptions'] = $GLOBALS['wgDBTableOptions'];
 565+ return $vars;
 566+ }
562567 }
563568
564569 /**
Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -1331,18 +1331,6 @@
13321332 return $this->mServer;
13331333 }
13341334
1335 - public function replaceVars( $ins ) {
1336 - $varnames = array( 'wgDBprefix' );
1337 - if ( $this->mFlags & DBO_SYSDBA ) {
1338 - $varnames[] = '_OracleDefTS';
1339 - $varnames[] = '_OracleTempTS';
1340 - }
1341 -
1342 - $ins = $this->replaceGlobalVars( $ins, $varnames );
1343 -
1344 - return parent::replaceVars( $ins );
1345 - }
1346 -
13471335 public function getSearchEngine() {
13481336 return 'SearchOracle';
13491337 }
Index: trunk/phase3/includes/db/Database.php
@@ -225,6 +225,7 @@
226226 protected $mLBInfo = array();
227227 protected $mFakeSlaveLag = null, $mFakeMaster = false;
228228 protected $mDefaultBigSelects = null;
 229+ protected $mSchemaVars = false;
229230
230231 # ------------------------------------------------------------------------------
231232 # Accessors
@@ -2473,6 +2474,17 @@
24742475 }
24752476
24762477 /**
 2478+ * Set variables to be used in sourceFile/sourceStream, in preference to the
 2479+ * ones in $GLOBALS. If an array is set here, $GLOBALS will not be used at
 2480+ * all. If it's set to false, $GLOBALS will be used.
 2481+ *
 2482+ * @param $vars False, or array mapping variable name to value.
 2483+ */
 2484+ function setSchemaVars( $vars ) {
 2485+ $this->mSchemaVars = $vars;
 2486+ }
 2487+
 2488+ /**
24772489 * Read and execute commands from an open file handle
24782490 * Returns true on success, error string or exception on failure (depending on object's error ignore settings)
24792491 * @param $fp String: File handle
@@ -2547,8 +2559,8 @@
25482560 }
25492561
25502562 /**
2551 - * Database independent variable replacement, replaces a set of named variables
2552 - * in a sql statement with the contents of their global variables.
 2563+ * Database independent variable replacement, replaces a set of variables
 2564+ * in a sql statement with their contents as given by $this->getSchemaVars().
25532565 * Supports '{$var}' `{$var}` and / *$var* / (without the spaces) style variables
25542566 *
25552567 * '{$var}' should be used for text and is passed through the database's addQuotes method
@@ -2558,16 +2570,17 @@
25592571 * / *$var* / is just encoded, besides traditional dbprefix and tableoptions it's use should be avoided
25602572 *
25612573 * @param $ins String: SQL statement to replace variables in
2562 - * @param $varnames Array: Array of global variable names to replace
25632574 * @return String The new SQL statement with variables replaced
25642575 */
2565 - protected function replaceGlobalVars( $ins, $varnames ) {
2566 - foreach ( $varnames as $var ) {
2567 - if ( isset( $GLOBALS[$var] ) ) {
2568 - $ins = str_replace( '\'{$' . $var . '}\'', $this->addQuotes( $GLOBALS[$var] ), $ins ); // replace '{$var}'
2569 - $ins = str_replace( '`{$' . $var . '}`', $this->addIdentifierQuotes( $GLOBALS[$var] ), $ins ); // replace `{$var}`
2570 - $ins = str_replace( '/*$' . $var . '*/', $this->strencode( $GLOBALS[$var] ) , $ins ); // replace /*$var*/
2571 - }
 2576+ protected function replaceSchemaVars( $ins ) {
 2577+ $vars = $this->getSchemaVars();
 2578+ foreach ( $vars as $var => $value ) {
 2579+ // replace '{$var}'
 2580+ $ins = str_replace( '\'{$' . $var . '}\'', $this->addQuotes( $value ), $ins );
 2581+ // replace `{$var}`
 2582+ $ins = str_replace( '`{$' . $var . '}`', $this->addIdentifierQuotes( $value ), $ins );
 2583+ // replace /*$var*/
 2584+ $ins = str_replace( '/*$' . $var . '*/', $this->strencode( $value ) , $ins );
25722585 }
25732586 return $ins;
25742587 }
@@ -2576,14 +2589,8 @@
25772590 * Replace variables in sourced SQL
25782591 */
25792592 protected function replaceVars( $ins ) {
2580 - $varnames = array(
2581 - 'wgDBserver', 'wgDBname', 'wgDBintlname', 'wgDBuser',
2582 - 'wgDBpassword', 'wgDBsqluser', 'wgDBsqlpassword',
2583 - 'wgDBadminuser', 'wgDBadminpassword', 'wgDBTableOptions',
2584 - );
 2593+ $ins = $this->replaceSchemaVars( $ins );
25852594
2586 - $ins = $this->replaceGlobalVars( $ins, $varnames );
2587 -
25882595 // Table prefixes
25892596 $ins = preg_replace_callback( '!/\*(?:\$wgDBprefix|_)\*/([a-zA-Z_0-9]*)!',
25902597 array( $this, 'tableNameCallback' ), $ins );
@@ -2596,6 +2603,27 @@
25972604 }
25982605
25992606 /**
 2607+ * Get schema variables. If none have been set via setSchemaVars(), then
 2608+ * use some defaults from the current object.
 2609+ */
 2610+ protected function getSchemaVars() {
 2611+ if ( $this->mSchemaVars ) {
 2612+ return $this->mSchemaVars;
 2613+ } else {
 2614+ return $this->getDefaultSchemaVars();
 2615+ }
 2616+ }
 2617+
 2618+ /**
 2619+ * Get schema variables to use if none have been set via setSchemaVars().
 2620+ * Override this in derived classes to provide variables for tables.sql
 2621+ * and SQL patch files.
 2622+ */
 2623+ protected function getDefaultSchemaVars() {
 2624+ return array();
 2625+ }
 2626+
 2627+ /**
26002628 * Table name callback
26012629 * @private
26022630 */
Index: trunk/phase3/includes/db/LBFactory.php
@@ -55,6 +55,14 @@
5656 }
5757
5858 /**
 59+ * Set the instance to be the given object
 60+ */
 61+ static function setInstance( $instance ) {
 62+ self::destroyInstance();
 63+ self::$instance = $instance;
 64+ }
 65+
 66+ /**
5967 * Construct a factory based on a configuration array (typically from $wgLBFactoryConf)
6068 */
6169 abstract function __construct( $conf );
Index: trunk/phase3/includes/db/LBFactory_Single.php
@@ -0,0 +1,57 @@
 2+<?php
 3+
 4+/**
 5+ * An LBFactory class that always returns a single database object.
 6+ */
 7+class LBFactory_Single extends LBFactory {
 8+ protected $lb;
 9+
 10+ /**
 11+ * @param $conf An associative array with one member:
 12+ * - connection: The DatabaseBase connection object
 13+ */
 14+ function __construct( $conf ) {
 15+ $this->lb = new LoadBalancer_Single( $conf );
 16+ }
 17+
 18+ function newMainLB( $wiki = false ) {
 19+ return $this->lb;
 20+ }
 21+
 22+ function getMainLB( $wiki = false ) {
 23+ return $this->lb;
 24+ }
 25+
 26+ function newExternalLB( $cluster, $wiki = false ) {
 27+ return $this->lb;
 28+ }
 29+
 30+ function &getExternalLB( $cluster, $wiki = false ) {
 31+ return $this->lb;
 32+ }
 33+
 34+ function forEachLB( $callback, $params = array() ) {
 35+ call_user_func_array( $callback, array_merge( array( $this->lb ), $params ) );
 36+ }
 37+}
 38+
 39+/**
 40+ * Helper class for LBFactory_Single.
 41+ */
 42+class LoadBalancer_Single extends LoadBalancer {
 43+ var $db;
 44+
 45+ function __construct( $params ) {
 46+ $this->db = $params['connection'];
 47+ parent::__construct( array( 'servers' => array( array(
 48+ 'type' => $this->db->getType(),
 49+ 'host' => $this->db->getServer(),
 50+ 'dbname' => $this->db->getDBname(),
 51+ 'load' => 1,
 52+ ) ) ) );
 53+ }
 54+
 55+ function reallyOpenConnection( $server, $dbNameOverride = false ) {
 56+ return $this->db;
 57+ }
 58+}
Property changes on: trunk/phase3/includes/db/LBFactory_Single.php
___________________________________________________________________
Added: svn:eol-style
159 + native
Index: trunk/phase3/includes/installer/Installer.php
@@ -556,6 +556,27 @@
557557 }
558558
559559 /**
 560+ * Install step which adds a row to the site_stats table with appropriate
 561+ * initial values.
 562+ */
 563+ public function populateSiteStats( DatabaseInstaller $installer ) {
 564+ $status = $installer->getConnection();
 565+ if ( !$status->isOK() ) {
 566+ return $status;
 567+ }
 568+ $status->value->insert( 'site_stats', array(
 569+ 'ss_row_id' => 1,
 570+ 'ss_total_views' => 0,
 571+ 'ss_total_edits' => 0,
 572+ 'ss_good_articles' => 0,
 573+ 'ss_total_pages' => 0,
 574+ 'ss_users' => 0,
 575+ 'ss_admins' => 0,
 576+ 'ss_images' => 0 ) );
 577+ return Status::newGood();
 578+ }
 579+
 580+ /**
560581 * Exports all wg* variables stored by the installer into global scope.
561582 */
562583 public function exportVars() {
@@ -1098,7 +1119,7 @@
10991120 break;
11001121 }
11011122
1102 - $text = Http::get( $url . $file );
 1123+ $text = Http::get( $url . $file, array( 'timeout' => 3 ) );
11031124 unlink( $dir . $file );
11041125
11051126 if ( $text == 'exec' ) {
@@ -1202,11 +1223,12 @@
12031224 * @param $installer DatabaseInstaller so we can make callbacks
12041225 * @return array
12051226 */
1206 - protected function getInstallSteps( DatabaseInstaller &$installer ) {
 1227+ protected function getInstallSteps( DatabaseInstaller $installer ) {
12071228 $coreInstallSteps = array(
12081229 array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ),
12091230 array( 'name' => 'tables', 'callback' => array( $installer, 'createTables' ) ),
12101231 array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
 1232+ array( 'name' => 'stats', 'callback' => array( $this, 'populateSiteStats' ) ),
12111233 array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ),
12121234 array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ),
12131235 array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
@@ -1254,16 +1276,17 @@
12551277 $installResults = array();
12561278 $installer = $this->getDBInstaller();
12571279 $installer->preInstall();
 1280+ $installer->setupSchemaVars();
12581281 $steps = $this->getInstallSteps( $installer );
12591282 foreach( $steps as $stepObj ) {
12601283 $name = $stepObj['name'];
12611284 call_user_func_array( $startCB, array( $name ) );
12621285
12631286 // Perform the callback step
1264 - $status = call_user_func_array( $stepObj['callback'], array( &$installer ) );
 1287+ $status = call_user_func( $stepObj['callback'], $installer );
12651288
12661289 // Output and save the results
1267 - call_user_func_array( $endCB, array( $name, $status ) );
 1290+ call_user_func( $endCB, $name, $status );
12681291 $installResults[$name] = $status;
12691292
12701293 // If we've hit some sort of fatal, we need to bail.
@@ -1364,6 +1387,10 @@
13651388 $user->setEmail( $this->getVar( '_AdminEmail' ) );
13661389 }
13671390 $user->saveSettings();
 1391+
 1392+ // Update user count
 1393+ $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
 1394+ $ssUpdate->doUpdate();
13681395 }
13691396 $status = Status::newGood();
13701397
@@ -1400,7 +1427,7 @@
14011428 *
14021429 * @return Status
14031430 */
1404 - protected function createMainpage( DatabaseInstaller &$installer ) {
 1431+ protected function createMainpage( DatabaseInstaller $installer ) {
14051432 $status = Status::newGood();
14061433 try {
14071434 // STUPID STUPID $wgTitle. PST calls getUserSig(), which joyfully
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -305,8 +305,6 @@
306306
307307 '''MyISAM''' may be faster in single-user or read-only installations.
308308 MyISAM databases tend to get corrupted more often than InnoDB databases.",
309 - 'config-mysql-egine-mismatch' => "'''Warning:''' you requested the $1 storage engine, but the existing database uses the $2 engine.
310 -This upgrade script can't convert it, so it will remain $2.",
311309 'config-mysql-charset' => 'Database character set:',
312310 'config-mysql-binary' => 'Binary',
313311 'config-mysql-utf8' => 'UTF-8',
@@ -314,8 +312,6 @@
315313 This is more efficient than MySQL's UTF-8 mode, and allows you to use the full range of Unicode characters.
316314
317315 In '''UTF-8 mode''', MySQL will know what character set your data is in, and can present and convert it appropriately, but it will not let you store characters above the [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes Basic Multilingual Plane].",
318 - 'config-mysql-charset-mismatch' => "'''Warning:''' you requested the $1 schema, but the existing database has the $2 schema.
319 - This upgrade script can't convert it, so it will remain $2.",
320316 'config-site-name' => 'Name of wiki:',
321317 'config-site-name-help' => "This will appear in the title bar of the browser and in various other places.",
322318 'config-site-name-blank' => 'Enter a site name.',
@@ -467,6 +463,7 @@
468464 'config-install-interwiki-sql' => 'Could not find file <code>interwiki.sql</code>.',
469465 'config-install-interwiki-exists' => "'''Warning''': The interwiki table seems to already have entries.
470466 Skipping default list.",
 467+ 'config-install-stats' => 'Initializing statistics',
471468 'config-install-secretkey' => 'Generating secret key',
472469 'config-insecure-secret' => "'''Warning:''' Unable to create a secure <code>$1</code>.
473470 Consider changing it manually.",
@@ -1125,8 +1122,6 @@
11261123
11271124 '''MyISAM''' можа быць хутчэйшай у вікі з адным удзельнікам, ці толькі для чытаньня.
11281125 Базы зьвестак на MyISAM вядомыя тым, што ў іх зьвесткі шкодзяцца нашмат часьцей за InnoDB.",
1129 - 'config-mysql-egine-mismatch' => "'''Папярэджаньне:''' Вы зрабілі запыт на рухавік сховішча $1, але існуючая база зьвестак выкарыстоўвае рухавік $2.
1130 -Гэтае абнаўленьне ня можа вырашыць гэтую праблему, рухавік сховішча застанецца $2.",
11311126 'config-mysql-charset' => 'Кадаваньне базы зьвестак:',
11321127 'config-mysql-binary' => 'Двайковае',
11331128 'config-mysql-utf8' => 'UTF-8',
@@ -1134,8 +1129,6 @@
11351130 Гэта болей эфэктыўна за рэжым MySQL UTF-8, і дазваляе Вам выкарыстоўваць увесь дыяпазон сымбаляў Unicode.
11361131
11371132 У '''рэжыме UTF-8''', MySQL ведае, якая табліцы сымбаляў выкарыстоўваецца ў Вашых зьвестках, і можа адпаведна прадстаўляць і канвэртаваць іх, але гэта не дазволіць Вам захоўваць сымбалі па-за межамі [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes Базавага шматмоўнага дыяпазону].",
1138 - 'config-mysql-charset-mismatch' => "'''Папярэджаньне:''' Вы зрабілі запыт на схему $1, але існуючая база зьвестак выкарыстоўвае схему $2.
1139 -Гэтае абнаўленьне ня можа вырашыць гэтую праблему, таму будзе пакінутая $2.",
11401133 'config-site-name' => 'Назва вікі:',
11411134 'config-site-name-help' => 'Назва будзе паказвацца ў загалоўку браўзэра і ў некаторых іншых месцах.',
11421135 'config-site-name-blank' => 'Увядзіце назву сайта.',
@@ -1542,8 +1535,6 @@
15431536 Това е по-ефективно от UTF-8 режима на MySQL и позволява използването на пълния набор от символи в Уникод.
15441537
15451538 В '''UTF-8 режим''' MySQL ще знае в кой набор от символи са данните от уикито и ще може да ги показва и променя по подходящ начин, но няма да позволява складиране на символи извън [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes Основния многоезичен набор].",
1546 - 'config-mysql-charset-mismatch' => "'''Предупреждение:''' заявена е $1 схема, но съществуващата база от данни е с $2 схема.
1547 - Скриптът за надграждане не може да я преобразува, затова тя ще остане $2.",
15481539 'config-site-name' => 'Име на уикито:',
15491540 'config-site-name-help' => 'Това име ще се показва в заглавната лента на браузъра и на различни други места.',
15501541 'config-site-name-blank' => 'Необходимо е да се въведе име на уикито.',
@@ -2296,8 +2287,6 @@
22972288
22982289 '''MyISAM''' ist in Einzelnutzerumgebungen sowie bei schreibgeschützten Wikis schneller.
22992290 Bei MyISAM-Datenbanken treten tendenziell häufiger Fehler auf als bei InnoDB-Datenbanken.",
2300 - 'config-mysql-egine-mismatch' => "'''Warnung:''' Als Speicher-Engine wurde $1 ausgewählt, während die Datenbank $2 verwendet.
2301 -Das Aktualisierungsskript kann die Speicher-Engine nicht konvertieren, so dass weiterhin $2 verwendet wird.",
23022291 'config-mysql-charset' => 'Datenbankzeichensatz:',
23032292 'config-mysql-binary' => 'binär',
23042293 'config-mysql-utf8' => 'UTF-8',
@@ -2306,8 +2295,6 @@
23072296
23082297 Im '''UTF-8-Modus''' wird MySQL den Zeichensatz der Daten erkennen und sie richtig anzeigen und konvertieren,
23092298 allerdings können keine Zeichen außerhalb des [http://de.wikipedia.org/wiki/Basic_Multilingual_Plane#Gliederung_in_Ebenen_und_Bl.C3.B6cke ''Basic Multilingual Plane'' (BMP)] gespeichert werden.",
2310 - 'config-mysql-charset-mismatch' => "'''Warnung:''' Als Datenbankzeichensatz wurde $1 ausgewählt, während die Datenbank $2 verwendet.
2311 -Das Aktualisierungsskript kann den Datenbankzeichensatz nicht konvertieren, so dass weiterhin $2 verwendet wird.",
23122299 'config-site-name' => 'Name des Wikis:',
23132300 'config-site-name-help' => 'Er wird in der Titelleiste des Browsers, wie auch verschiedenen anderen Stellen, genutzt.',
23142301 'config-site-name-blank' => 'Sitenamen angeben.',
@@ -2702,13 +2689,9 @@
27032690
27042691 '''MyISAM''' es más rápido en instalaciones de usuario único o de sólo lectura.
27052692 Las bases de datos MyISAM tienden a corromperse más a menudo que las bases de datos InnoDB.",
2706 - 'config-mysql-egine-mismatch' => "'''Atención:''' Solicitó el motor de almacenamento $1, pero el existente en la base de datos es el motor $2.
2707 -Este código de actualización no lo puede convertir, de modo que permanecerá como $2.",
27082693 'config-mysql-charset' => 'Conjunto de caracteres de la base de datos:',
27092694 'config-mysql-binary' => 'Binario',
27102695 'config-mysql-utf8' => 'UTF-8',
2711 - 'config-mysql-charset-mismatch' => "'''Advertencia:''' Has solicitado el esquema $1, pero la base de datos existente tiene el esquema $2.
2712 -Este script de actualización no puede convertirlo, de modo que permanecerá como $2.",
27132696 'config-site-name' => 'Nombre del wiki:',
27142697 'config-site-name-help' => 'Esto aparecerá en la barra de título del navegador y en varios otros lugares.',
27152698 'config-site-name-blank' => 'Ingresar un nombre de sitio.',
@@ -3326,8 +3309,6 @@
33273310 'config-mysql-engine-help' => "'''InnoDB''' est presque toujours la meilleure option, car il supporte bien l'[http://fr.wikipedia.org/wiki/Ordonnancement_dans_les_syst%C3%A8mes_d%27exploitation ordonnancement].
33283311
33293312 '''MyISAM''' peut être plus rapide dans les installations monoposte ou en lecture seule. Les bases de données MyISAM ont tendance à se corrompre plus souvent que celles d'InnoDB.",
3330 - 'config-mysql-egine-mismatch' => "'''Attention:''' Vous avez demandé le moteur de stockage $1, mais la base de données existante utilise le moteur $2.
3331 -Ce script de mise à niveau ne peut pas le convertir, il restera $2.",
33323313 'config-mysql-charset' => 'Jeu de caractères de la base de données :',
33333314 'config-mysql-binary' => 'Binaire',
33343315 'config-mysql-utf8' => 'UTF-8',
@@ -3335,8 +3316,6 @@
33363317
33373318 En ''mode binaire'', MediaWiki stocke le texte UTF-8 dans des champs binaires de la base de données. C'est plus efficace que le ''mode UTF-8'' de MySQL, et vous permet d'utiliser toute la gamme des caractères Unicode.
33383319 En ''mode UTF-8'', MySQL connaîtra le jeu de caractères de vos données et pourra présenter et convertir les données de manière appropriée, mais il ne vous laissera pas stocker les caractères au-dessus du [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes plan multilingue de base] (en anglais).",
3339 - 'config-mysql-charset-mismatch' => "'''Attention:''' Vous avez demandé le schéma $1, mais la base de données existante a le schéma $2.
3340 -Ce script de mise à niveau ne peut pas le convertir, il restera $2.",
33413320 'config-site-name' => 'Nom du wiki :',
33423321 'config-site-name-help' => 'Il apparaîtra dans la barre de titre du navigateur et en divers autres endroits.',
33433322 'config-site-name-blank' => 'Entrez un nom de site.',
@@ -3789,8 +3768,6 @@
37903769
37913770 '''MyISAM''' é máis rápido en instalacións de usuario único e de só lectura.
37923771 As bases de datos MyISAM tenden a se corromper máis a miúdo ca as bases de datos InnoDB.",
3793 - 'config-mysql-egine-mismatch' => "'''Atención:''' Solicitou o motor de almacenamento $1, mais o existente na base de datos é o motor $2.
3794 -Esta escritura de actualización non o pode converter, de modo que permanecerá $2.",
37953772 'config-mysql-charset' => 'Conxunto de caracteres da base de datos:',
37963773 'config-mysql-binary' => 'Binario',
37973774 'config-mysql-utf8' => 'UTF-8',
@@ -3799,8 +3776,6 @@
38003777
38013778 No '''modo UTF-8''', MySQL saberá o xogo de caracteres dos seus datos e pode presentar e converter os datos de maneira axeitada,
38023779 pero non lle deixará gardar caracteres por riba do [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes plan multilingüe básico].",
3803 - 'config-mysql-charset-mismatch' => "'''Atención:''' Solicitou o esquema $1, mais o existente na base de datos é o esquema $2.
3804 -Esta escritura de actualización non o pode converter, de modo que permanecerá $2.",
38053780 'config-site-name' => 'Nome do wiki:',
38063781 'config-site-name-help' => 'Isto aparecerá na barra de títulos do navegador e noutros lugares.',
38073782 'config-site-name-blank' => 'Escriba o nome do sitio.',
@@ -5013,8 +4988,6 @@
50144989
50154990 '''MyISAM''' pote esser plus rapide in installationes a usator singule o a lectura solmente.
50164991 Le bases de datos MyISAM tende a esser corrumpite plus frequentemente que le base de datos InnoDB.",
5017 - 'config-mysql-egine-mismatch' => "'''Aviso:''' tu requestava le motor de immagazinage $1, ma le base de datos existente usa le motor $2.
5018 -Iste script de actualisation non pote converter lo, dunque illo remanera $2.",
50194992 'config-mysql-charset' => 'Codification de characteres in le base de datos:',
50204993 'config-mysql-binary' => 'Binari',
50214994 'config-mysql-utf8' => 'UTF-8',
@@ -5022,8 +4995,6 @@
50234996 Isto es plus efficiente que le modo UTF-8 de MySQL, e permitte usar le rango complete de characteres Unicode.
50244997
50254998 In '''modo UTF-8''', MySQL cognoscera le codification de characteres usate pro tu dats, e pote presentar e converter lo appropriatemente, ma illo non permittera immagazinar characteres supra le [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes Plano Multilingue Basic].",
5026 - 'config-mysql-charset-mismatch' => "'''Aviso:''' tu requestava le schema $1, ma le base de datos existente ha le schema $2.
5027 -Iste script de actualisation non pote converter lo, dunque illo remanera $2.",
50284999 'config-site-name' => 'Nomine del wiki:',
50295000 'config-site-name-help' => 'Isto apparera in le barra de titulo del navigator e in varie altere locos.',
50305001 'config-site-name-blank' => 'Entra un nomine de sito.',
@@ -5494,8 +5465,6 @@
54955466
54965467 '''MyISAM''' mungkin lebih cepat dalam instalasi pengguna-tunggal atau hanya-baca.
54975468 Basis data MyISAM cenderung lebih sering rusak daripada basis data InnoDB.",
5498 - 'config-mysql-egine-mismatch' => "'''Peringatan:''' Anda meminta mesin penyimpanan $1, tapi basis data yang ada menggunakan mesin $2.
5499 -Skrip pemutakhiran ini tidak dapat mengubahnya, sehingga akan tetap $2.",
55005469 'config-mysql-charset' => 'Set karakter basis data:',
55015470 'config-mysql-binary' => 'Biner',
55025471 'config-mysql-utf8' => 'UTF-8',
@@ -5503,8 +5472,6 @@
55045473 Ini lebih efisien daripada modus UTF-8 MySQL dan memungkinkan Anda untuk menggunakan ragam penuh karakter Unicode.
55055474
55065475 Dalam '''modus UTF-8''', MySQL akan tahu apa set karakter data dan dapat menampilkan dan mengubahnya sesuai keperluan, tetapi tidak akan mengizinkan Anda menyimpan karakter di atas [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes Basic Multilingual Plane].",
5507 - 'config-mysql-charset-mismatch' => "'''Peringatan:''' Anda meminta skema $1, tapi basis data yang ada menggunakan skema $2.
5508 -Skrip pemutakhiran ini tidak dapat mengubahnya, sehingga akan tetap $2.",
55095476 'config-site-name' => 'Nama wiki:',
55105477 'config-site-name-help' => 'Ini akan muncul di bilah judul peramban dan di berbagai tempat lainnya.',
55115478 'config-site-name-blank' => 'Masukkan nama situs.',
@@ -5990,8 +5957,6 @@
59915958
59925959 '''MyISAM'''は、利用者が1人の場合、あるいは読み込み専用でインストールする場合に、より処理が早くなるでしょう。
59935960 ただし、MyISAMのデータベースは、InnoDBより高頻度で破損する傾向があります。",
5994 - 'config-mysql-egine-mismatch' => "'''警告:'''$1ストレージエンジンが要求されましたが、既存のデータベースは$2エンジンを使用します。
5995 -この更新スクリプトは、これに対応していません、$2のままになります。",
59965961 'config-mysql-charset' => 'データベースの文字セット:',
59975962 'config-mysql-binary' => 'バイナリ',
59985963 'config-mysql-utf8' => 'UTF-8',
@@ -6000,8 +5965,6 @@
60015966
60025967 '''UTF-8形式'''では、MySQLは、なんの文字集合がデータのなかに含まれているかを知り、それに対して適切な提示と変換をするでしょうが、
60035968 [http://ja.wikipedia.org/wiki/%E5%9F%BA%E6%9C%AC%E5%A4%9A%E8%A8%80%E8%AA%9E%E9%9D%A2 基本多言語面]の外にある文字を格納できるようにはなりません。",
6004 - 'config-mysql-charset-mismatch' => "'''警告:'''$1スキーマが要求されましたが、既存のデータベースは$2スキーマです。
6005 -この更新スクリプトは、これに対応していませんので、$2のままになります。",
60065969 'config-site-name' => 'ウィキの名前:',
60075970 'config-site-name-help' => 'この事象はブラウザのタイトルバーと他の様々な場所において出現する。',
60085971 'config-site-name-blank' => 'サイト名を入力してください。',
@@ -6814,8 +6777,6 @@
68156778
68166779 '''MyISAM''' може да е побрз кај инсталациите наменети за само еден корисник или незаписни инсталации (само читање).
68176780 Базите на податоци од MyISAM почесто се расипуваат од базите на InnoDB.",
6818 - 'config-mysql-egine-mismatch' => "'''Предупредување:''' го побаравте складишниот погон $1, но постоечката база на податоци го користи погонот $2.
6819 -Оваа надградбена скрипта не може да го претвори, и затоа ќе остане на $2.",
68206781 'config-mysql-charset' => 'Збир знаци за базата:',
68216782 'config-mysql-binary' => 'Бинарен',
68226783 'config-mysql-utf8' => 'UTF-8',
@@ -6823,8 +6784,6 @@
68246785 Ова е поефикасно отколку TF-8 режимот на MySQL, и ви овозможува да ја користите целата палета на уникодни знаци.
68256786
68266787 Во '''UTF-8 режим''', MySQL ќе знае на кој збир знаци припаѓаат вашите податоци, и може соодветно да ги претстави и претвори, но нема да ви дозволи да складиратезнаци над [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes Основната повеќејазична рамнина].",
6827 - 'config-mysql-charset-mismatch' => "'''Предупредување:''' ја побаравте шемата $1, но постоечката база на податоци ја има шемата $2.
6828 -Оваа надградбена скрипта не може да ја претвори, па затоа ќе остане на $2.",
68296788 'config-site-name' => 'Име на викито:',
68306789 'config-site-name-help' => 'Ова ќе се појавува во заглавната лента на прелистувачот и на разни други места.',
68316790 'config-site-name-blank' => 'Внесете име на мрежното место.',
@@ -7468,8 +7427,6 @@
74697428
74707429 '''MyISAM''' is bij een zeer beperkt aantal gebruikers mogelijk sneller, of als de wiki alleen-lezen is.
74717430 MyISAM-databases raken vaker corrupt dan InnoDB-databases.",
7472 - 'config-mysql-egine-mismatch' => "'''Waarschuwing:''' u wilt de opslagwijze $1 gebruiken, maar de bestaande database gebruikt de opslagwijze $2.
7473 -Dit upgradescript kan de opslagwijze niet converteren, dus het blijft $2.",
74747431 'config-mysql-charset' => 'Tekenset voor de database:',
74757432 'config-mysql-binary' => 'Binair',
74767433 'config-mysql-utf8' => 'UTF-8',
@@ -7478,8 +7435,6 @@
74797436
74807437 In '''UTF-8-modus''' kent MySQL de tekenset van uw gegevens en kan de databaseserver ze juist weergeven en converteren.
74817438 Het is dat niet mogelijk tekens op te slaan die de \"[http://nl.wikipedia.org/wiki/Lijst_van_Unicode-subbereiken#Basic_Multilingual_Plane Basic Multilingual Plane]\" te boven gaan.",
7482 - 'config-mysql-charset-mismatch' => "'''Waarschuwing:''' u wilt het schema $1 gebruiken, maar de bestaande database gebruikt het schema $2.
7483 -Dit upgradescript kan het schema niet converteren, dus het blijft $2.",
74847439 'config-site-name' => 'Naam van de wiki:',
74857440 'config-site-name-help' => 'Deze naam verschijnt in de titelbalk van browsers en op andere plaatsen.',
74867441 'config-site-name-blank' => 'Geef een naam op voor de site.',
@@ -7966,8 +7921,6 @@
79677922
79687923 '''MyISAM''' kan være raskere i enbruker- eller les-bare-installasjoner.
79697924 MyISAM-databaser har en tendens til å bli ødelagt oftere enn InnoDB-databaser.",
7970 - 'config-mysql-egine-mismatch' => "'''Advarsel:''' du ba om lagringsmotoren $1, men den eksisterende databasen bruker motoren $2.
7971 -Dette oppgraderingsskriptet kan ikke konvertere den, så den vil forbli $2.",
79727925 'config-mysql-charset' => 'Databasetegnsett:',
79737926 'config-mysql-binary' => 'Binær',
79747927 'config-mysql-utf8' => 'UTF-8',
@@ -7976,8 +7929,6 @@
79777930
79787931 I '''UTF-8 mode''' vil MySQL vite hvilket tegnsett dataene dine er i og kan presentere og konvertere det på en riktig måte,
79797932 men det vil ikke la deg lagre tegn over «[http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes the Basic Multilingual Plane]».",
7980 - 'config-mysql-charset-mismatch' => "'''Advarsel:''' du ba om skjemaet $1, men den eksisterende databasen bruker skjemaet $2.
7981 -Dette oppgraderingsskriptet kan ikke konvertere det, så det vil forbli $2.",
79827933 'config-site-name' => 'Navn på wiki:',
79837934 'config-site-name-help' => 'Dette vil vises i tittellinjen i nettleseren og diverse andre steder.',
79847935 'config-site-name-blank' => 'Skriv inn et nettstedsnavn.',
@@ -8706,8 +8657,6 @@
87078658
87088659 '''MyISAM''' a peul esse pi lest an instalassion për n'utent sol o mach an letura.
87098660 La base ëd dàit MyISAM a tira a corompse pi 'd soens che la base ëd dàit InnoDB.",
8710 - 'config-mysql-egine-mismatch' => "'''Avis:''' it l'has ciamà ël motor ëd memorisassion $1, ma la base ëd dàit esistenta a deuvra ël motor $2.
8711 -Cost senari d'agiornament a peul pa convertilo, parèj a restrà $2.",
87128661 'config-mysql-charset' => 'Ansem ëd caràter dla base ëd dàit:',
87138662 'config-mysql-binary' => 'Binari',
87148663 'config-mysql-utf8' => 'UTF-8',
@@ -8715,8 +8664,6 @@
87168665 Sòn a l'é pi eficient che la manera UTF-8 ëd MySQL, e a-j përmët ëd dovré l'ansema antregh ëd caràter Unicode.
87178666
87188667 An '''manera UTF-8''', MySQL a conossrà an che ansem ëd caràter a son ij sò dat, e a peul presenteje e convertije apropriatament, ma a-j lassa pa memorisé ij caràter ëdzora al [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes pian multilenghìstich ëd base].",
8719 - 'config-mysql-charset-mismatch' => "'''Avis:''' a l'ha ciamà lë schema $1, ma la base ëd dàit esistenta a l'ha lë schema $2.
8720 -Cost senari d'agiornament a peul pa convertilo, parèj a restrà $2.",
87218668 'config-site-name' => 'Nòm ëd la wiki:',
87228669 'config-site-name-help' => "Sòn a comparirà ant la bara dël tìtol dël navigador e an vàire d'àutri pòst.",
87238670 'config-site-name-blank' => "Ch'a buta un nòm ëd sit.",
@@ -9187,7 +9134,6 @@
91889135
91899136 '''MyISAM''' pode ser mais rápido no modo de utilizador único ou em instalações somente para leitura.
91909137 As bases de dados MyISAM tendem a ficar corrompidas com maior frequência do que as bases de dados InnoDB.",
9191 - 'config-mysql-egine-mismatch' => "'''Aviso:''' pediu a plataforma de armazenamento $1, mas a base de dados existente usa a plataforma $2. Este código de actualização não pode fazer a conversão, por isso permanecerá como $2.",
91929138 'config-mysql-charset' => 'Conjunto de caracteres da base de dados:',
91939139 'config-mysql-binary' => 'Binary',
91949140 'config-mysql-utf8' => 'UTF-8',
@@ -9196,7 +9142,6 @@
91979143
91989144 No modo '''UTF-8''', o MySQL saberá em que conjunto de caracteres os seus dados estão e pode apresentá-los e convertê-los da forma mais adequada,
91999145 mas não lhe permitirá armazenar caracteres acima do [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes Plano Multilingue Básico].",
9200 - 'config-mysql-charset-mismatch' => "'''Aviso:''' pediu o esquema ''(schema)'' $1, mas a base de dados existente usa o esquema $2. Este código de actualização não pode fazer a conversão, por isso permanecerá como $2.",
92019146 'config-site-name' => 'Nome da wiki:',
92029147 'config-site-name-help' => 'Este nome aparecerá no título da janela do seu browser e em vários outros sítios.',
92039148 'config-site-name-blank' => 'Introduza o nome do site.',
@@ -9798,8 +9743,6 @@
97999744 'config-mysql-engine-help' => "'''InnoDB''' почти всегда предпочтительнее, так как он лучше справляется с параллельным доступом.
98009745
98019746 '''MyISAM''' может оказаться быстрее для вики с одним пользователем или с минимальным количеством поступающих правок, однако базы данных на нём портятся чаще, чем на InnoDB.",
9802 - 'config-mysql-egine-mismatch' => "'''Внимание:''' Вы запросили метод хранения $1, однако существующая база данных использует $2.
9803 -Этот сценарий обновления не может изменить преобразовать его и поэтому метод хранения останется $2.",
98049747 'config-mysql-charset' => 'Набор символов (кодовая таблица) базы данных:',
98059748 'config-mysql-binary' => 'Двоичный',
98069749 'config-mysql-utf8' => 'UTF-8',
@@ -9807,8 +9750,6 @@
98089751 Это более эффективно, чем ''UTF-8 режим'' MySQL, и позволяет использовать полный набор символов Unicode.
98099752
98109753 В '''режиме UTF-8''' MySQL будет знать в какой кодировке находятся Ваши данные и может отображать и преобразовывать их соответствующим образом, но это не позволит вам хранить символы выше [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes Базовой Многоязыковой Плоскости].",
9811 - 'config-mysql-charset-mismatch' => "'''Внимание.''' Вы запросили схему $1, но существующая база данных имеет схему $2.
9812 -Этот сценарий обновления не сможет преобразовать схему, она останется типа $2.",
98139754 'config-site-name' => 'Название вики:',
98149755 'config-site-name-help' => 'Название будет отображаться в заголовке окна браузера и в некоторых других местах вики.',
98159756 'config-site-name-blank' => 'Введите название сайта.',
@@ -10623,14 +10564,12 @@
1062410565 'config-mysql-engine-help' => "'''InnoDB'''通常是最佳选项,因为它对并发操作有着良好的支持。
1062510566
1062610567 '''MyISAM'''在单用户或只读环境下可能会有更快的性能表现。但MyISAM数据库出错的概率一般要大于InnoDB数据库。",
10627 - 'config-mysql-egine-mismatch' => "'''警告:'''您选择了使用$1存储引擎,但现有的数据库使用了$2引擎。升级脚本无法转换它,故将保持$2。",
1062810568 'config-mysql-charset' => '数据库字符集:',
1062910569 'config-mysql-binary' => '二进制',
1063010570 'config-mysql-utf8' => 'UTF-8',
1063110571 'config-mysql-charset-help' => "在'''二进制模式'''下,MediaWiki会将UTF-8编码的文本存于数据库的二进制字段中。相对于MySQL的UTF-8模式,这种方法效率更高,并允许您使用全范围的Unicode字符。
1063210572
1063310573 在'''UTF-8模式'''下,MySQL将知道您数据使用的字符集,并能适当地提供和转换内容。但这样做您将无法在数据库中存储[http://zh.wikipedia.org/wiki/基本多文种平面 基本多文种平面]以外的字符。",
10634 - 'config-mysql-charset-mismatch' => "'''警告:'''您选择了使用$1模式,但现有的数据库使用了$2模式。升级脚本无法转换它,故将保持$2。",
1063510574 'config-site-name' => 'Wiki的名称:',
1063610575 'config-site-name-help' => '填入的内容会出现在浏览器的标题栏以及其他多处位置中。',
1063710576 'config-site-name-blank' => '输入网站的名称。',
Index: trunk/phase3/includes/installer/SqliteInstaller.php
@@ -89,25 +89,20 @@
9090 return Status::newGood();
9191 }
9292
93 - public function getConnection() {
 93+ public function openConnection() {
9494 global $wgSQLiteDataDir;
9595
9696 $status = Status::newGood();
97 - if( is_null( $this->db ) ) {
98 - $dir = $this->getVar( 'wgSQLiteDataDir' );
99 - $dbName = $this->getVar( 'wgDBname' );
100 -
101 - try {
102 - # FIXME: need more sensible constructor parameters, e.g. single associative array
103 - # Setting globals kind of sucks
104 - $wgSQLiteDataDir = $dir;
105 - $this->db = new DatabaseSqlite( false, false, false, $dbName );
106 - $status->value = $this->db;
107 - } catch ( DBConnectionError $e ) {
108 - $status->fatal( 'config-sqlite-connection-error', $e->getMessage() );
109 - }
110 - } else {
111 - $status->value = $this->db;
 97+ $dir = $this->getVar( 'wgSQLiteDataDir' );
 98+ $dbName = $this->getVar( 'wgDBname' );
 99+ try {
 100+ # FIXME: need more sensible constructor parameters, e.g. single associative array
 101+ # Setting globals kind of sucks
 102+ $wgSQLiteDataDir = $dir;
 103+ $db = new DatabaseSqlite( false, false, false, $dbName );
 104+ $status->value = $db;
 105+ } catch ( DBConnectionError $e ) {
 106+ $status->fatal( 'config-sqlite-connection-error', $e->getMessage() );
112107 }
113108 return $status;
114109 }
Index: trunk/phase3/includes/installer/DatabaseInstaller.php
@@ -95,14 +95,14 @@
9696 }
9797
9898 /**
99 - * Connect to the database using the administrative user/password currently
100 - * defined in the session. On success, return the connection, on failure,
 99+ * Open a connection to the database using the administrative user/password
 100+ * currently defined in the session, without any caching. Returns a status
 101+ * object. On success, the status object will contain a Database object in
 102+ * its value member.
101103 *
102 - * This may be called multiple times, so the result should be cached.
103 - *
104104 * @return Status
105105 */
106 - public abstract function getConnection();
 106+ public abstract function openConnection();
107107
108108 /**
109109 * Create the database and return a Status object indicating success or
@@ -113,6 +113,29 @@
114114 public abstract function setupDatabase();
115115
116116 /**
 117+ * Connect to the database using the administrative user/password currently
 118+ * defined in the session. Returns a status object. On success, the status
 119+ * object will contain a Database object in its value member.
 120+ *
 121+ * This will return a cached connection if one is available.
 122+ *
 123+ * @return DatabaseBase
 124+ */
 125+ public function getConnection() {
 126+ if ( $this->db ) {
 127+ return Status::newGood( $this->db );
 128+ }
 129+ $status = $this->openConnection();
 130+ if ( $status->isOK() ) {
 131+ $this->db = $status->value;
 132+ // Enable autocommit
 133+ $this->db->clearFlag( DBO_TRX );
 134+ $this->db->commit();
 135+ }
 136+ return $status;
 137+ }
 138+
 139+ /**
117140 * Create database tables from scratch.
118141 *
119142 * @return Status
@@ -142,7 +165,7 @@
143166 }
144167 // Resume normal operations
145168 if( $status->isOk() ) {
146 - LBFactory::enableBackend();
 169+ $this->enableLB();
147170 }
148171 return $status;
149172 }
@@ -155,13 +178,56 @@
156179 public abstract function getLocalSettings();
157180
158181 /**
 182+ * Override this to provide DBMS-specific schema variables, to be
 183+ * substituted into tables.sql and other schema files.
 184+ */
 185+ public function getSchemaVars() {
 186+ return array();
 187+ }
 188+
 189+ /**
 190+ * Set appropriate schema variables in the current database connection.
 191+ *
 192+ * This should be called after any request data has been imported, but before
 193+ * any write operations to the database.
 194+ */
 195+ public function setupSchemaVars() {
 196+ $status = $this->getConnection();
 197+ if ( $status->isOK() ) {
 198+ $status->value->setSchemaVars( $this->getSchemaVars() );
 199+ }
 200+ }
 201+
 202+ /**
 203+ * Set up LBFactory so that wfGetDB() etc. works.
 204+ * We set up a special LBFactory instance which returns the current
 205+ * installer connection.
 206+ */
 207+ public function enableLB() {
 208+ $status = $this->getConnection();
 209+ if ( !$status->isOK() ) {
 210+ throw new MWException( __METHOD__.': unexpected DB connection error' );
 211+ }
 212+ LBFactory::setInstance( new LBFactory_Single( array(
 213+ 'connection' => $status->value ) ) );
 214+ }
 215+
 216+ /**
 217+ * Get a Database connection object. Throw an exception if we can't get one.
 218+ *
 219+ * @return DatabaseBase
 220+ */
 221+ public function getConnectionOrDie() {
 222+ }
 223+
 224+ /**
159225 * Perform database upgrades
160226 *
161227 * @return Boolean
162228 */
163229 public function doUpgrade() {
164 - # Maintenance scripts like wfGetDB()
165 - LBFactory::enableBackend();
 230+ $this->setupSchemaVars();
 231+ $this->enableLB();
166232
167233 $ret = true;
168234 ob_start( array( $this, 'outputHandler' ) );
@@ -201,16 +267,6 @@
202268 }
203269
204270 /**
205 - * Return any table options to be applied to all tables that don't
206 - * override them.
207 - *
208 - * @return Array
209 - */
210 - public function getTableOptions() {
211 - return array();
212 - }
213 -
214 - /**
215271 * Construct and initialise parent.
216272 * This is typically only called from Installer::getDBInstaller()
217273 */
Index: trunk/phase3/includes/installer/MysqlInstaller.php
@@ -111,25 +111,21 @@
112112 return $status;
113113 }
114114
115 - public function getConnection() {
 115+ public function openConnection() {
116116 $status = Status::newGood();
117 - if( is_null( $this->db ) ) {
118 - try {
119 - $this->db = new DatabaseMysql(
120 - $this->getVar( 'wgDBserver' ),
121 - $this->getVar( '_InstallUser' ),
122 - $this->getVar( '_InstallPassword' ),
123 - false,
124 - false,
125 - 0,
126 - $this->getVar( 'wgDBprefix' )
127 - );
128 - $status->value = $this->db;
129 - } catch ( DBConnectionError $e ) {
130 - $status->fatal( 'config-connection-error', $e->getMessage() );
131 - }
132 - } else {
133 - $status->value = $this->db;
 117+ try {
 118+ $db = new DatabaseMysql(
 119+ $this->getVar( 'wgDBserver' ),
 120+ $this->getVar( '_InstallUser' ),
 121+ $this->getVar( '_InstallPassword' ),
 122+ false,
 123+ false,
 124+ 0,
 125+ $this->getVar( 'wgDBprefix' )
 126+ );
 127+ $status->value = $db;
 128+ } catch ( DBConnectionError $e ) {
 129+ $status->fatal( 'config-connection-error', $e->getMessage() );
134130 }
135131 return $status;
136132 }
@@ -158,9 +154,9 @@
159155 if ( preg_match( '/^latin1/', $row->Collation ) ) {
160156 $existingSchema = 'mysql4';
161157 } elseif ( preg_match( '/^utf8/', $row->Collation ) ) {
162 - $existingSchema = 'mysql5';
 158+ $existingSchema = 'utf8';
163159 } elseif ( preg_match( '/^binary/', $row->Collation ) ) {
164 - $existingSchema = 'mysql5-binary';
 160+ $existingSchema = 'binary';
165161 } else {
166162 $existingSchema = false;
167163 $this->parent->showMessage( 'config-unknown-collation' );
@@ -177,11 +173,9 @@
178174 }
179175
180176 if ( $existingSchema && $existingSchema != $this->getVar( '_MysqlCharset' ) ) {
181 - $this->parent->showMessage( 'config-mysql-charset-mismatch', $this->getVar( '_MysqlCharset' ), $existingSchema );
182177 $this->setVar( '_MysqlCharset', $existingSchema );
183178 }
184179 if ( $existingEngine && $existingEngine != $this->getVar( '_MysqlEngine' ) ) {
185 - $this->parent->showMessage( 'config-mysql-egine-mismatch', $this->getVar( '_MysqlEngine' ), $existingEngine );
186180 $this->setVar( '_MysqlEngine', $existingEngine );
187181 }
188182
@@ -445,16 +439,36 @@
446440 return $status;
447441 }
448442
449 - public function getTableOptions() {
450 - return array( 'engine' => $this->getVar( '_MysqlEngine' ),
451 - 'default charset' => $this->getVar( '_MysqlCharset' ) );
 443+ /**
 444+ * Return any table options to be applied to all tables that don't
 445+ * override them.
 446+ *
 447+ * @return String
 448+ */
 449+ protected function getTableOptions() {
 450+ $options = array();
 451+ if ( $this->getVar( '_MysqlEngine' ) !== null ) {
 452+ $options[] = "ENGINE=" . $this->getVar( '_MysqlEngine' );
 453+ }
 454+ if ( $this->getVar( '_MysqlCharset' ) !== null ) {
 455+ $options[] = 'DEFAULT CHARSET=' . $this->getVar( '_MysqlCharset' );
 456+ }
 457+ return implode( ', ', $options );
452458 }
453459
 460+ /**
 461+ * Get variables to substitute into tables.sql and the SQL patch files.
 462+ */
 463+ public function getSchemaVars() {
 464+ return array(
 465+ 'wgDBTableOptions' => $this->getTableOptions(),
 466+ );
 467+ }
 468+
454469 public function getLocalSettings() {
455470 $dbmysql5 = wfBoolToStr( $this->getVar( 'wgDBmysql5', true ) );
456 - $prefix = $this->getVar( 'wgDBprefix' );
457 - $opts = $this->getTableOptions();
458 - $tblOpts = "ENGINE=" . $opts['engine'] . ', DEFAULT CHARSET=' . $opts['default charset'];
 471+ $prefix = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgDBprefix' ) );
 472+ $tblOpts = LocalSettingsGenerator::escapePhpString( $this->getTableOptions() );
459473 return
460474 "# MySQL specific settings
461475 \$wgDBprefix = \"{$prefix}\";
Index: trunk/phase3/includes/installer/OracleInstaller.php
@@ -109,11 +109,11 @@
110110 return $status;
111111 }
112112
113 - public function getConnection() {
 113+ public function openConnection() {
114114 $status = Status::newGood();
115115 try {
116116 if ( $this->useSysDBA ) {
117 - $this->db = new DatabaseOracle(
 117+ $db = new DatabaseOracle(
118118 $this->getVar( 'wgDBserver' ),
119119 $this->getVar( '_InstallUser' ),
120120 $this->getVar( '_InstallPassword' ),
@@ -122,7 +122,7 @@
123123 $this->getVar( 'wgDBprefix' )
124124 );
125125 } else {
126 - $this->db = new DatabaseOracle(
 126+ $db = new DatabaseOracle(
127127 $this->getVar( 'wgDBserver' ),
128128 $this->getVar( 'wgDBuser' ),
129129 $this->getVar( 'wgDBpassword' ),
@@ -131,7 +131,7 @@
132132 $this->getVar( 'wgDBprefix' )
133133 );
134134 }
135 - $status->value = $this->db;
 135+ $status->value = $db;
136136 } catch ( DBConnectionError $e ) {
137137 $status->fatal( 'config-connection-error', $e->getMessage() );
138138 }
@@ -176,12 +176,6 @@
177177 }
178178
179179 if ( !$this->db->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
180 - /**
181 - * The variables $_OracleDefTS, $_OracleTempTS are used by maintenance/oracle/user.sql
182 - * Set here for fetching in DatabaseOracle::replaceVars()
183 - */
184 - $GLOBALS['_OracleDefTS'] = $this->getVar( '_OracleDefTS' );
185 - $GLOBALS['_OracleTempTS'] = $this->getVar( '_OracleTempTS' );
186180 $this->db->setFlag( DBO_DDLMODE );
187181 $error = $this->db->sourceFile( "$IP/maintenance/oracle/user.sql" );
188182 if ( $error !== true || !$this->db->selectDB( $this->getVar( 'wgDBuser' ) ) ) {
@@ -203,6 +197,15 @@
204198 return $status;
205199 }
206200
 201+ public function getSchemaVars() {
 202+ /**
 203+ * The variables $_OracleDefTS, $_OracleTempTS are used by maintenance/oracle/user.sql
 204+ */
 205+ return array(
 206+ '_OracleDefTS' => $this->getVar( '_OracleDefTS' ),
 207+ '_OracleTempTS' => $this->getVar( '_OracleTempTS' ),
 208+ );
 209+ }
207210
208211 public function getLocalSettings() {
209212 $prefix = $this->getVar( 'wgDBprefix' );
Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -98,21 +98,17 @@
9999 return $status;
100100 }
101101
102 - function getConnection($database = 'template1') {
 102+ function openConnection( $database = 'template1' ) {
103103 $status = Status::newGood();
104 - if( is_null( $this->db ) ) {
105 - try {
106 - $this->db = new DatabasePostgres(
107 - $this->getVar( 'wgDBserver' ),
108 - $this->getVar( '_InstallUser' ),
109 - $this->getVar( '_InstallPassword' ),
110 - $database );
111 - $status->value = $this->db;
112 - } catch ( DBConnectionError $e ) {
113 - $status->fatal( 'config-connection-error', $e->getMessage() );
114 - }
115 - } else {
116 - $status->value = $this->db;
 104+ try {
 105+ $db = new DatabasePostgres(
 106+ $this->getVar( 'wgDBserver' ),
 107+ $this->getVar( '_InstallUser' ),
 108+ $this->getVar( '_InstallPassword' ),
 109+ $database );
 110+ $status->value = $db;
 111+ } catch ( DBConnectionError $e ) {
 112+ $status->fatal( 'config-connection-error', $e->getMessage() );
117113 }
118114 return $status;
119115 }
Index: trunk/phase3/includes/AutoLoader.php
@@ -396,8 +396,10 @@
397397 'LBFactory' => 'includes/db/LBFactory.php',
398398 'LBFactory_Multi' => 'includes/db/LBFactory_Multi.php',
399399 'LBFactory_Simple' => 'includes/db/LBFactory.php',
 400+ 'LBFactory_Single' => 'includes/db/LBFactory_Single.php',
400401 'LikeMatch' => 'includes/db/Database.php',
401402 'LoadBalancer' => 'includes/db/LoadBalancer.php',
 403+ 'LoadBalancer_Single' => 'includes/db/LBFactory_Single.php',
402404 'LoadMonitor' => 'includes/db/LoadMonitor.php',
403405 'LoadMonitor_MySQL' => 'includes/db/LoadMonitor.php',
404406 'MySQLField' => 'includes/db/DatabaseMysql.php',

Follow-up revisions

RevisionCommit summaryAuthorDate
r81083Removed getConnectionOrDie(), accidentally added in r80957tstarling03:54, 27 January 2011
r81084* Fixed Oracle new installer support, broken by r80957. This is a minimal pat...tstarling08:25, 27 January 2011
r84589MFT installer changes thru head (+db and autoloader changes from r80957)demon00:26, 23 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80892* Cleanup massive duplication across Database constructors. Default implement...demon18:36, 24 January 2011

Comments

#Comment by 😂 (talk | contribs)   16:25, 25 January 2011

Looks good, thanks for the fixes. One minor nitpick: getConnectionOrDie() seems unused. From the name is looks like a predecesor to openConnection().

#Comment by Tim Starling (talk | contribs)   23:22, 26 January 2011

I was going to use it in DatabaseInstaller::enableLB(), but I changed my mind.

I'll write a bug report about the PostgreSQL issue.

#Comment by Tim Starling (talk | contribs)   02:34, 27 January 2011

Added a comment to bug 26612.

Status & tagging log