Don't save and restore the interwiki table
authorTim Starling <tstarling@wikimedia.org>
Tue, 4 Sep 2018 00:51:18 +0000 (10:51 +1000)
committerKunal Mehta <legoktm@member.fsf.org>
Tue, 4 Sep 2018 04:26:06 +0000 (21:26 -0700)
In fact it always has zero rows. Well, at least it does until
ApiQuerySiteinfoTest::testInterwikiMap() inserts two rows without using
@group Database, and then it has two rows from then on. It's meant to
have zero rows.

This saves time and memory.

Revert of f17feae3a991de9f54e0f57d91fe95bf84211fcb

Change-Id: Ibdb12ff941d2cb47143bdff176072ef9078fa0f7

tests/phpunit/MediaWikiTestCase.php

index 17147eb..3917ca6 100644 (file)
@@ -8,7 +8,6 @@ use Psr\Log\LoggerInterface;
 use Wikimedia\Rdbms\IDatabase;
 use Wikimedia\Rdbms\IMaintainableDatabase;
 use Wikimedia\Rdbms\Database;
-use Wikimedia\Rdbms\IResultWrapper;
 use Wikimedia\Rdbms\LBFactory;
 use Wikimedia\TestingAccessWrapper;
 
@@ -101,12 +100,6 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
         */
        private $mwGlobalsToUnset = [];
 
-       /**
-        * Holds original contents of interwiki table
-        * @var IResultWrapper
-        */
-       private $interwikiTable = null;
-
        /**
         * Holds original loggers which have been replaced by setLogger()
         * @var LoggerInterface[]
@@ -530,12 +523,6 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                        }
                }
 
-               // Store contents of interwiki table in case it changes.  Unfortunately, we seem to have no
-               // way to do this only when needed, because tablesUsed can be changed mid-test.
-               if ( $this->db ) {
-                       $this->interwikiTable = $this->db->select( 'interwiki', '*', '', __METHOD__ );
-               }
-
                // Reset all caches between tests.
                $this->resetNonServiceCaches();
 
@@ -1763,19 +1750,6 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                        // Reset the table's sequence too.
                        $db->resetSequenceForTable( $tableName, __METHOD__ );
                }
-
-               if ( $tableName === 'interwiki' ) {
-                       if ( !$this->interwikiTable ) {
-                               // @todo We should probably throw here, but this causes test failures that I
-                               // can't figure out, so for now we silently continue.
-                               return;
-                       }
-                       $db->insert(
-                               'interwiki',
-                               array_values( array_map( 'get_object_vars', iterator_to_array( $this->interwikiTable ) ) ),
-                               __METHOD__
-                       );
-               }
        }
 
        private static function unprefixTable( &$tableName, $ind, $prefix ) {