r60816 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60815‎ | r60816 | r60817 >
Date:00:31, 8 January 2010
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
For r60757: implement Database::getType() explicitly in each subclass, to make Roan happy.
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseIbm_db2.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMssql.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseMysql.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseSqlite.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseMysql.php
@@ -7,6 +7,10 @@
88 * @see Database
99 */
1010 class DatabaseMysql extends DatabaseBase {
 11+ function getType() {
 12+ return 'mysql';
 13+ }
 14+
1115 /*private*/ function doQuery( $sql ) {
1216 if( $this->bufferResults() ) {
1317 $ret = mysql_query( $sql, $this->mConn );
Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -192,6 +192,10 @@
193193 wfRunHooks( 'DatabaseOraclePostInit', array( &$this ) );
194194 }
195195
 196+ function getType() {
 197+ return 'oracle';
 198+ }
 199+
196200 function cascadingDeletes() {
197201 return true;
198202 }
Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -84,6 +84,10 @@
8585
8686 }
8787
 88+ function getType() {
 89+ return 'postgres';
 90+ }
 91+
8892 function cascadingDeletes() {
8993 return true;
9094 }
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php
@@ -391,8 +391,11 @@
392392 return $this->mDBname;
393393 }
394394 }
 395+
 396+ function getType() {
 397+ return 'ibm_db2';
 398+ }
395399
396 -
397400 ######################################
398401 # Setup
399402 ######################################
Index: trunk/phase3/includes/db/Database.php
@@ -287,13 +287,7 @@
288288 /**
289289 * Get the type of the DBMS, as it appears in $wgDBtype.
290290 */
291 - function getType() {
292 - if ( preg_match( '/^Database(\w+)$/', get_class( $this ), $m ) ) {
293 - return strtolower( $m[1] );
294 - } else {
295 - throw new MWException( get_class( $this ) .'::getType: unable to determine type.' );
296 - }
297 - }
 291+ abstract function getType();
298292
299293 #------------------------------------------------------------------------------
300294 # Other functions
Index: trunk/phase3/includes/db/DatabaseMssql.php
@@ -45,6 +45,10 @@
4646
4747 }
4848
 49+ function getType() {
 50+ return 'mssql';
 51+ }
 52+
4953 /**
5054 * todo: check if these should be true like parent class
5155 */
Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -32,6 +32,10 @@
3333 $this->open( $server, $user, $password, $dbName );
3434 }
3535
 36+ function getType() {
 37+ return 'sqlite';
 38+ }
 39+
3640 /**
3741 * @todo: check if it should be true like parent class
3842 */

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r60757Add a Database::getType() function so that we can get rid of $wgDBtype in fav...tstarling00:22, 7 January 2010

Comments

#Comment by Simetrical (talk | contribs)   23:15, 10 January 2010

I like the previous way better, this is a waste of code in subclasses.

Status & tagging log