Fix a SUMIF warning when having different length of arrays provided as input

Closes #873
This commit is contained in:
Fräntz Miccoli 2019-02-01 15:01:19 +01:00 committed by Adrien Crivelli
parent 27255ce808
commit 9a208b31d8
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
3 changed files with 30 additions and 2 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Fixed
- Whitelist `tsv` extension when opening CSV files [#429](https://github.com/PHPOffice/PhpSpreadsheet/issues/429)
- Fix a SUMIF warning with some versions of PHP when having different length of arrays provided as input [#873](https://github.com/PHPOffice/PhpSpreadsheet/pull/873)
## [1.7.0] - 2019-05-26

View File

@ -1224,11 +1224,12 @@ class MathTrig
}
$testCondition = '=' . $arg . $condition;
$sumValue = array_key_exists($key, $sumArgs) ? $sumArgs[$key] : 0;
if (is_numeric($sumArgs[$key]) &&
if (is_numeric($sumValue) &&
Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
// Is it a value within our criteria and only numeric can be added to the result
$returnValue += $sumArgs[$key];
$returnValue += $sumValue;
}
}

View File

@ -94,4 +94,30 @@ return [
[1],
],
],
[
3,
[
[1],
[0],
[1]
],
1,
[
[3],
[4] // less elements in sum array
]
],
[
3,
[
[1],
[0] // less elements in condition array
],
1,
[
[3],
[4],
[5]
]
]
];