r107932 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107931‎ | r107932 | r107933 >
Date:19:55, 3 January 2012
Author:mah
Status:resolved (Comments)
Tags:tstarling 
Comment:
Fix Bug 33384 - database drivers cannot be provided by extension
Author: Adam Wight

Love the simplicity of this fix.
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/Database.php
@@ -675,9 +675,9 @@
676676 'mysql', 'postgres', 'sqlite', 'oracle', 'mssql', 'ibm_db2'
677677 );
678678 $dbType = strtolower( $dbType );
 679+ $class = 'Database' . ucfirst( $dbType );
679680
680681 if( in_array( $dbType, $canonicalDBTypes ) ) {
681 - $class = 'Database' . ucfirst( $dbType );
682682 return new $class(
683683 isset( $p['host'] ) ? $p['host'] : false,
684684 isset( $p['user'] ) ? $p['user'] : false,
@@ -686,6 +686,8 @@
687687 isset( $p['flags'] ) ? $p['flags'] : 0,
688688 isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : 'get from global'
689689 );
 690+ } elseif (class_exists($class)) {
 691+ return new $class($p);
690692 } else {
691693 return null;
692694 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r108051follow up r107932 with w/s fixesmah16:43, 4 January 2012
r108164Followup r107932...reedy18:49, 5 January 2012
r113601Bug 35162 - Change in Database api break extension MSSQLBackCompat...reedy23:40, 11 March 2012

Comments

#Comment by Reedy (talk | contribs)   20:06, 3 January 2012

But should we really be just attempting to instantiate foo class, just because it exists?

It feels somewhat icky, but I'm not sure having say a hook to modify the allowable database types is any/much better.

#Comment by MarkAHershberger (talk | contribs)   21:07, 3 January 2012

I agree that it felt strange. Maybe I should get Tim to give us his input?

#Comment by Reedy (talk | contribs)   21:36, 3 January 2012

Yeah possibly, and/or Brion

#Comment by Reedy (talk | contribs)   20:07, 3 January 2012

Probably should have a RELEASE-NOTES entry to go with it also

#Comment by Nikerabbit (talk | contribs)   07:33, 4 January 2012

Whitespace.

#Comment by 😂 (talk | contribs)   18:28, 5 January 2012

Use Reflection to make sure it extends DatabaseBase before instantiating it.

#Comment by Reedy (talk | contribs)   18:41, 5 January 2012

^

Status & tagging log