From 1907426ef2820bc22701229eb25b775024199ed4 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 16 Mar 2009 20:21:45 +0000 Subject: [PATCH] (bug 14990) Parser tests works again with PostgreSQL Based on a patch by Brent G: http://bug-attachment.wikimedia.org/attachment.cgi?id=5933 --- RELEASE-NOTES | 1 + maintenance/parserTests.inc | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 563030dde7..6ee3e0d921 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index cb9e8aedbb..1df63383d7 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -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 -- 2.20.1