Merge #16919 - Fix Uncaught TypeError: array_fill(): Argument #2 ($count) must be of type int, string

Pull-request: #16919

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2021-05-28 18:03:44 +02:00
commit 8343c28e6c
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
2 changed files with 45 additions and 7 deletions

View File

@ -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,

View File

@ -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
);