diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index a6449c77..5f2af864 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -5236,8 +5236,6 @@ class Calculation $aReferences = Coordinate::extractAllCellReferencesInRange($range); $range = "'" . $worksheetName . "'" . '!' . $range; if (!isset($aReferences[1])) { - $currentCol = ''; - $currentRow = 0; // Single cell in range sscanf($aReferences[0], '%[A-Z]%d', $currentCol, $currentRow); if ($worksheet->cellExists($aReferences[0])) { @@ -5248,8 +5246,6 @@ class Calculation } else { // Extract cell data for all cells in the range foreach ($aReferences as $reference) { - $currentCol = ''; - $currentRow = 0; // Extract range sscanf($reference, '%[A-Z]%d', $currentCol, $currentRow); if ($worksheet->cellExists($reference)) { diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index cc3d17e8..72790e9a 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -317,7 +317,9 @@ class Cells // Store new values $stored = $newCollection->cache->setMultiple($newValues); - $this->destructIfNeeded($stored, $newCollection, 'Failed to copy cells in cache'); + if ($stored === false) { + $this->destructIfNeeded($newCollection, 'Failed to copy cells in cache'); + } return $newCollection; } @@ -362,7 +364,9 @@ class Cells $this->currentCell->detach(); $stored = $this->cache->set($this->cachePrefix . $this->currentCoordinate, $this->currentCell); - $this->destructIfNeeded($stored, $this, "Failed to store cell {$this->currentCoordinate} in cache"); + if ($stored === false) { + $this->destructIfNeeded($this, "Failed to store cell {$this->currentCoordinate} in cache"); + } $this->currentCellIsDirty = false; } @@ -370,13 +374,11 @@ class Cells $this->currentCell = null; } - private function destructIfNeeded(bool $stored, self $cells, string $message): void + private function destructIfNeeded(self $cells, string $message): void { - if (!$stored) { - $cells->__destruct(); + $cells->__destruct(); - throw new PhpSpreadsheetException($message); - } + throw new PhpSpreadsheetException($message); } /** @@ -416,7 +418,7 @@ class Cells $this->storeCurrentCell(); // Return null if requested entry doesn't exist in collection - if (!$this->has($cellCoordinate)) { + if ($this->has($cellCoordinate) === false) { return null; }