From 4ef087080d38ae852d864e0b47aa7e8f10dc36f2 Mon Sep 17 00:00:00 2001 From: Platonides Date: Mon, 21 Feb 2011 23:19:26 +0000 Subject: [PATCH] maintenance/commandLine.inc loads DefaultSettings, LocalSettings and then runs Setup.php 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 | 2 +- tests/phpunit/bootstrap.php | 7 ------- tests/phpunit/phpunit.php | 22 +++++++++++++++++++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index a7dfae1f90..37c7b5921f 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -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' ) diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index f96ab003cc..b023fdcf94 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -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(); diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php index d196c1a9f6..5c4db3a0ad 100755 --- a/tests/phpunit/phpunit.php +++ b/tests/phpunit/phpunit.php @@ -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'; -- 2.20.1