(bug 14990) Parser tests works again with PostgreSQL
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 16 Mar 2009 20:21:45 +0000 (20:21 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 16 Mar 2009 20:21:45 +0000 (20:21 +0000)
Based on a patch by Brent G: http://bug-attachment.wikimedia.org/attachment.cgi?id=5933

RELEASE-NOTES
maintenance/parserTests.inc

index 563030d..6ee3e0d 100644 (file)
@@ -269,6 +269,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   don't use PathInfo or short urls
 * (bug 17990) trackback.php now has a trackback.php5 alias and works with 
   $wgScriptExtension
+* (bug 14990) Parser tests works again with PostgreSQL
 
 == API changes in 1.15 ==
 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions
index cb9e8ae..1df6338 100644 (file)
@@ -616,7 +616,7 @@ class ParserTest {
         * the db will be visible to later tests in the run.
         */
        private function setupDatabase() {
-               global $wgDBprefix;
+               global $wgDBprefix, $wgDBtype;
                if ( $this->databaseSetupDone ) {
                        return;
                }
@@ -638,15 +638,16 @@ class ParserTest {
                $db = wfGetDB( DB_MASTER );
                $tables = $this->listTables();
 
-               if (!(strcmp($db->getServerVersion(), '4.1') < 0 and stristr($db->getSoftwareLink(), 'MySQL'))) {
+               if ( !( $wgDBtype == 'mysql' && strcmp( $db->getServerVersion(), '4.1' ) < 0 ) ) {
                        # Database that supports CREATE TABLE ... LIKE
-                       global $wgDBtype;
+                       
                        if( $wgDBtype == 'postgres' ) {
                                $def = 'INCLUDING DEFAULTS';
+                               $temporary = 'TEMPORARY';
                        } else {
                                $def = '';
                        }
-                       foreach ($tables as $tbl) {
+                       foreach ( $tables as $tbl ) {
                                # Clean up from previous aborted run.  So that table escaping
                                # works correctly across DB engines, we need to change the pre-
                                # fix back and forth so tableName() works right.
@@ -655,11 +656,11 @@ class ParserTest {
                                $this->changePrefix( 'parsertest_' );
                                $newTableName = $db->tableName( $tbl );
 
-                               if ( $db->tableExists( $tbl ) ) {
-                                       $db->query("DROP TABLE $newTableName");
+                               if ( $db->tableExists( $tbl ) && $wgDBtype != 'postgres' ) {
+                                       $db->query( "DROP TABLE $newTableName" );
                                }
                                # Create new table
-                               $db->query("CREATE $temporary TABLE $newTableName (LIKE $oldTableName $def)");
+                               $db->query( "CREATE $temporary TABLE $newTableName (LIKE $oldTableName $def)" );
                        }
                } else {
                        # Hack for MySQL versions < 4.1, which don't support