Fix to inappropriate replacement of count() with empty().... there may be others I've not spotted yet.

Improved debuglog in calculation engine.

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@85403 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2012-01-17 21:57:06 +00:00
parent 24a9eb285c
commit 21cce674c8
2 changed files with 9 additions and 7 deletions

View File

@ -2504,13 +2504,15 @@ class PHPExcel_Calculation {
$pad = $rpad = ', '; $pad = $rpad = ', ';
foreach($value as $row) { foreach($value as $row) {
if (is_array($row)) { if (is_array($row)) {
$returnMatrix[] = implode($pad,$row); $returnMatrix[] = implode($pad,array_map(array($this,'_showValue'),$row));
$rpad = '; '; $rpad = '; ';
} else { } else {
$returnMatrix[] = $row; $returnMatrix[] = $this->_showValue($row);
} }
} }
return '{ '.implode($rpad,$returnMatrix).' }'; return '{ '.implode($rpad,$returnMatrix).' }';
} elseif(is_string($value) && (trim($value,'"') == $value)) {
return '"'.$value.'"';
} elseif(is_bool($value)) { } elseif(is_bool($value)) {
return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE']; return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
} }
@ -3428,14 +3430,14 @@ class PHPExcel_Calculation {
$result = array(); $result = array();
if ((is_array($operand1)) && (!is_array($operand2))) { if ((is_array($operand1)) && (!is_array($operand2))) {
foreach($operand1 as $x => $operandData) { foreach($operand1 as $x => $operandData) {
$this->_writeDebug('Evaluating '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2)); $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2));
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack); $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack);
$r = $stack->pop(); $r = $stack->pop();
$result[$x] = $r['value']; $result[$x] = $r['value'];
} }
} elseif ((!is_array($operand1)) && (is_array($operand2))) { } elseif ((!is_array($operand1)) && (is_array($operand2))) {
foreach($operand2 as $x => $operandData) { foreach($operand2 as $x => $operandData) {
$this->_writeDebug('Evaluating '.$this->_showValue($operand1).' '.$operation.' '.$this->_showValue($operandData)); $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operand1).' '.$operation.' '.$this->_showValue($operandData));
$this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack); $this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack);
$r = $stack->pop(); $r = $stack->pop();
$result[$x] = $r['value']; $result[$x] = $r['value'];
@ -3443,14 +3445,14 @@ class PHPExcel_Calculation {
} else { } else {
if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); } if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); }
foreach($operand1 as $x => $operandData) { foreach($operand1 as $x => $operandData) {
$this->_writeDebug('Evaluating '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2[$x])); $this->_writeDebug('Evaluating Comparison '.$this->_showValue($operandData).' '.$operation.' '.$this->_showValue($operand2[$x]));
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,true); $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,true);
$r = $stack->pop(); $r = $stack->pop();
$result[$x] = $r['value']; $result[$x] = $r['value'];
} }
} }
// Log the result details // Log the result details
$this->_writeDebug('Evaluation Result is '.$this->_showTypeDetails($result)); $this->_writeDebug('Comparison Evaluation Result is '.$this->_showTypeDetails($result));
// And push the result onto the stack // And push the result onto the stack
$stack->push('Array',$result); $stack->push('Array',$result);
return true; return true;

View File

@ -340,7 +340,7 @@ class PHPExcel_ReferenceHelper
// Update workbook: named ranges // Update workbook: named ranges
if (!empty($pSheet->getParent()->getNamedRanges())) { if (count($pSheet->getParent()->getNamedRanges()) > 0) {
foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) { foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) {
if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) { if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) {
$namedRange->setRange( $namedRange->setRange(