maintenance/commandLine.inc loads DefaultSettings, LocalSettings and then runs Setup.php
authorPlatonides <platonides@users.mediawiki.org>
Mon, 21 Feb 2011 23:19:26 +0000 (23:19 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Mon, 21 Feb 2011 23:19:26 +0000 (23:19 +0000)
As Setup.php assigns variables based on the cache config, bootstrap.php was late on reseting them, as some objects were already created.
So we could end up with a SqlBagOStuff created there, which when later accessed (such as trying to invalidate the cache for a user) would
-as any non-sqlite SqlBagOStuff- open a new db connection. Which is precisely what we shall not be done when dealing with temporary tables
(and would indeed fail miserably due to not finding unittest_objectcache table).

In summary, reenabling temporary tables disabled in r79411.

tests/phpunit/MediaWikiTestCase.php
tests/phpunit/bootstrap.php
tests/phpunit/phpunit.php

index a7dfae1..37c7b59 100644 (file)
@@ -115,7 +115,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                $prefix = $dbType != 'oracle' ? self::DB_PREFIX : self::ORA_DB_PREFIX;
                
                $this->dbClone = new CloneDatabase( $this->db, $tables, $prefix );
-               $this->dbClone->useTemporaryTables( false ); //reported problems with temp tables, disabling until fixed
+               $this->dbClone->useTemporaryTables( $this->useTemporaryTables );
                $this->dbClone->cloneTableStructure();
                
                if ( $dbType == 'oracle' )
index f96ab00..b023fdc 100644 (file)
@@ -28,12 +28,5 @@ dependencies.
 EOF;
 }
 
-global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgUseDatabaseMessages, $wgMemc;
-$wgMainCacheType = CACHE_NONE;
-$wgMessageCacheType = CACHE_NONE;
-$wgParserCacheType = CACHE_NONE;
-$wgUseDatabaseMessages = false; # Set for future resets
-$wgMemc = new FakeMemCachedClient;
-
 /** @todo Check if this is really needed */
 MessageCache::destroyInstance();
index d196c1a..5c4db3a 100755 (executable)
@@ -15,7 +15,27 @@ $IP = dirname( dirname( dirname( __FILE__ ) ) );
 define( 'MW_PHPUNIT_TEST', true );
 
 // Start up MediaWiki in command-line mode
-require_once( "$IP/maintenance/commandLine.inc" );
+require_once( "$IP/maintenance/Maintenance.php" );
+
+class PHPUnitMaintClass extends Maintenance {
+       public function finalSetup() {
+               $settings = parent::finalSetup();
+
+               global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgUseDatabaseMessages;
+
+               $wgMainCacheType = CACHE_NONE;
+               $wgMessageCacheType = CACHE_NONE;
+               $wgParserCacheType = CACHE_NONE;
+               $wgUseDatabaseMessages = false; # Set for future resets
+       }
+       public function execute() { }
+       public function getDbType() {
+               return Maintenance::DB_ADMIN;
+       }
+}
+
+$maintClass = 'PHPUnitMaintClass';
+require( RUN_MAINTENANCE_IF_MAIN );
 
 // Assume UTC for testing purposes
 $wgLocaltimezone = 'UTC';