Fix reset interwiki table between tests
authorPwirth <wirth@hallowelt.biz>
Mon, 6 Aug 2018 16:27:00 +0000 (16:27 +0000)
committerPwirth <wirth@hallowelt.biz>
Tue, 14 Aug 2018 05:08:02 +0000 (05:08 +0000)
This fixes the following SQL error, when the interwikilinks table was
marked as used:
Fatal error: Uncaught exception 'Wikimedia\Rdbms\DBQueryError' with message 'A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?
Query: INSERT  INTO `unittest_interwiki` (1,2,3) VALUES ('Array','Array','Array')
Function: MediaWikiTestCase::resetDB

iterator_to_array on the result of the select of the interwiki table
returns an array with the first entry having the key 1. For
multi insert to work, the array must start on 0.
Change-Id: I3dc1be9e2f016709f451fe6e8d7cc60862c1ffea

tests/phpunit/MediaWikiTestCase.php

index 366806e..3565311 100644 (file)
@@ -1784,7 +1784,7 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                                        }
                                        $db->insert(
                                                'interwiki',
-                                               array_map( 'get_object_vars', iterator_to_array( $this->interwikiTable ) ),
+                                               array_values( array_map( 'get_object_vars', iterator_to_array( $this->interwikiTable ) ) ),
                                                __METHOD__
                                        );
                                }