diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php index d241723c7d..195046430d 100644 --- a/libraries/classes/InsertEdit.php +++ b/libraries/classes/InsertEdit.php @@ -267,7 +267,8 @@ class InsertEdit DatabaseInterface::CONNECT_USER, DatabaseInterface::QUERY_STORE ); - $rows = array_fill(0, $GLOBALS['cfg']['InsertRows'], false); + // Can be a string on some old configuration storage settings + $rows = array_fill(0, (int) $GLOBALS['cfg']['InsertRows'], false); return [ $result, diff --git a/test/classes/InsertEditTest.php b/test/classes/InsertEditTest.php index 0c977f8f01..e179554129 100644 --- a/test/classes/InsertEditTest.php +++ b/test/classes/InsertEditTest.php @@ -294,12 +294,52 @@ class InsertEditTest extends AbstractTestCase $this->assertFalse($result); } + public function dataProviderConfigValueInsertRows(): array + { + return [ + [ + 2, + [ + false, + false, + ], + ], + [ + '2', + [ + false, + false, + ], + ], + [ + 3, + [ + false, + false, + false, + ], + ], + [ + '3', + [ + false, + false, + false, + ], + ], + ]; + } + /** * Test for loadFirstRow + * + * @param string|int $configValue + * + * @dataProvider dataProviderConfigValueInsertRows */ - public function testLoadFirstRow(): void + public function testLoadFirstRow($configValue, array $rowsValue): void { - $GLOBALS['cfg']['InsertRows'] = 2; + $GLOBALS['cfg']['InsertRows'] = $configValue; $dbi = $this->getMockBuilder(DatabaseInterface::class) ->disableOriginalConstructor() @@ -327,10 +367,7 @@ class InsertEditTest extends AbstractTestCase $this->assertEquals( [ 'result1', - [ - false, - false, - ], + $rowsValue, ], $result );