From: Lucas Werkmeister Date: Thu, 12 Sep 2019 15:36:01 +0000 (+0200) Subject: Improve MediaWikiIntegrationTestCase::resetDB() X-Git-Tag: 1.34.0-rc.0~239^2 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=74fbb2c5c4b0a44929eabe483487fa6617b150b0;p=lhc%2Fweb%2Fwiklou.git Improve MediaWikiIntegrationTestCase::resetDB() Test the intersection of $tablesUsed with each set of tables separately and only update it afterwards. Without this fix, overlaps between the table groups would cause additional groups to be pulled in unnecessarily. Change-Id: I1b2a6eb47e061dee8a27fb4779809b4684c05104 --- diff --git a/tests/phpunit/MediaWikiIntegrationTestCase.php b/tests/phpunit/MediaWikiIntegrationTestCase.php index b738312725..373ea9a88d 100644 --- a/tests/phpunit/MediaWikiIntegrationTestCase.php +++ b/tests/phpunit/MediaWikiIntegrationTestCase.php @@ -1834,9 +1834,11 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { ]; $coreDBDataTables = array_merge( $userTables, $pageTables ); - // If any of the user or page tables were marked as used, we should clear all of them. + // some groups of tables are connected such that if any is used, all should be cleared + $extraTables = []; if ( array_intersect( $tablesUsed, $userTables ) ) { - $tablesUsed = array_unique( array_merge( $tablesUsed, $userTables ) ); + $extraTables[] = $userTables; + TestUserRegistry::clear(); // Reset $wgUser, which is probably 127.0.0.1, as its loaded data is probably not valid @@ -1846,7 +1848,10 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { $wgUser->clearInstanceCache( $wgUser->mFrom ); } if ( array_intersect( $tablesUsed, $pageTables ) ) { - $tablesUsed = array_unique( array_merge( $tablesUsed, $pageTables ) ); + $extraTables[] = $pageTables; + } + if ( $extraTables !== [] ) { + $tablesUsed = array_unique( array_merge( $tablesUsed, ...$extraTables ) ); } // Postgres uses mwuser/pagecontent