Make teardownTestDB() close any dangling connections before changing the prefix
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 5 Apr 2019 19:36:34 +0000 (12:36 -0700)
committerKrinkle <krinklemail@gmail.com>
Fri, 5 Apr 2019 19:52:40 +0000 (19:52 +0000)
Bug: T219673
Change-Id: I028fc16b874cac744f7215601eec754a76f31a3f

tests/phpunit/MediaWikiTestCase.php

index f43f0a9..5119d73 100644 (file)
@@ -1364,6 +1364,9 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                        JobQueueGroup::singleton()->get( $type )->delete();
                }
 
+               // T219673: close any connections from code that failed to call reuseConnection()
+               // or is still holding onto a DBConnRef instance (e.g. in a singleton).
+               MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->closeAll();
                CloneDatabase::changePrefix( self::$oldTablePrefix );
 
                self::$oldTablePrefix = false;