parsertest now destroy virtual table under SQLite
authorAntoine Musso <hashar@users.mediawiki.org>
Thu, 27 Oct 2011 17:12:53 +0000 (17:12 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Thu, 27 Oct 2011 17:12:53 +0000 (17:12 +0000)
Fix:
Bug 29912 - Unit tests break if parsertest tables are still present

The parserTest suite duplicate available tables. When using temporary table
it assumed every table are temporary. Under SQLite searchindex is a virtual
table and thus remained after a run of parserTests.php
As a side effect, when running the PHPUnit with that remaining table, it
caused a nice error:

The last attempted database query was:
"DELETE FROM unittest_parsertest_searchindex"
from within function "MediaWikiTestCase::resetDB".
Database returned error "1: SQL logic error or missing database"

This patch is not needed for REL1_18 continuous integration since we
never run the parserTests.php script.

RELEASE-NOTES-1.19
tests/parser/parserTest.inc

index 2577c26..1435066 100644 (file)
@@ -117,6 +117,7 @@ production.
    suppressed
 * (bug 31921) Magic words REVISIONDAY, REVISIONMONTH and REVISIONYEAR now give
   current values on preview
+* (bug 29912) Unit tests break if parsertest tables are still present
 
 === API changes in 1.19 ===
 * (bug 19838) siprop=interwikimap can now use the interwiki cache.
index 2b52fb5..694b7e2 100644 (file)
@@ -868,6 +868,13 @@ class ParserTest {
                $this->databaseSetupDone = false;
 
                if ( $this->useTemporaryTables ) {
+                       if( $this->db->getType() == 'sqlite' ) {
+                               # Under SQLite the searchindex table is virtual and need
+                               # to be explicitly destroyed. See bug 29912
+                               # See also MediaWikiTestCase::destroyDB()
+                               wfDebug( __METHOD__ . " explicitly destroying sqlite virtual table parsertest_searchindex\n" );
+                               $this->db->query( "DROP TABLE `parsertest_searchindex`" );
+                       }
                        # Don't need to do anything
                        $this->teardownGlobals();
                        return;