Fix a SUMIF warning when having different length of arrays provided as input
Closes #873
This commit is contained in:
		
							parent
							
								
									27255ce808
								
							
						
					
					
						commit
						9a208b31d8
					
				| @ -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 | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -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] | ||||
|         ] | ||||
|     ] | ||||
| ]; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Fräntz Miccoli
						Fräntz Miccoli