From 2bcaa01eccebb306a8b7f13b06242398740785dd Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sun, 29 Dec 2013 23:48:42 +0000 Subject: [PATCH] Bugfix: Work Item GH-193 - Fix to empty worksheet garbage collection when using cell caching --- Classes/PHPExcel/CachedObjectStorage/APC.php | 2 +- Classes/PHPExcel/CachedObjectStorage/DiscISAM.php | 2 +- Classes/PHPExcel/CachedObjectStorage/Igbinary.php | 2 +- Classes/PHPExcel/CachedObjectStorage/Memcache.php | 2 +- Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php | 2 +- Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php | 2 +- Classes/PHPExcel/CachedObjectStorage/PHPTemp.php | 2 +- Classes/PHPExcel/CachedObjectStorage/SQLite.php | 2 +- Classes/PHPExcel/CachedObjectStorage/SQLite3.php | 2 +- Classes/PHPExcel/CachedObjectStorage/Wincache.php | 2 +- changelog.txt | 1 + 11 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Classes/PHPExcel/CachedObjectStorage/APC.php b/Classes/PHPExcel/CachedObjectStorage/APC.php index 55454fa03..3a6b53d06 100644 --- a/Classes/PHPExcel/CachedObjectStorage/APC.php +++ b/Classes/PHPExcel/CachedObjectStorage/APC.php @@ -61,7 +61,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach * @throws PHPExcel_Exception */ protected function _storeData() { - if ($this->_currentCellIsDirty) { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) { diff --git a/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php b/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php index 1a319d0f7..5afc26b50 100644 --- a/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php +++ b/Classes/PHPExcel/CachedObjectStorage/DiscISAM.php @@ -65,7 +65,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage * @throws PHPExcel_Exception */ protected function _storeData() { - if ($this->_currentCellIsDirty) { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); fseek($this->_fileHandle,0,SEEK_END); diff --git a/Classes/PHPExcel/CachedObjectStorage/Igbinary.php b/Classes/PHPExcel/CachedObjectStorage/Igbinary.php index 6af87b3e7..aaee0217b 100644 --- a/Classes/PHPExcel/CachedObjectStorage/Igbinary.php +++ b/Classes/PHPExcel/CachedObjectStorage/Igbinary.php @@ -43,7 +43,7 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage * @throws PHPExcel_Exception */ protected function _storeData() { - if ($this->_currentCellIsDirty) { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject); diff --git a/Classes/PHPExcel/CachedObjectStorage/Memcache.php b/Classes/PHPExcel/CachedObjectStorage/Memcache.php index 2c33050ce..27ffc195e 100644 --- a/Classes/PHPExcel/CachedObjectStorage/Memcache.php +++ b/Classes/PHPExcel/CachedObjectStorage/Memcache.php @@ -65,7 +65,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage * @throws PHPExcel_Exception */ protected function _storeData() { - if ($this->_currentCellIsDirty) { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $obj = serialize($this->_currentObject); diff --git a/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php b/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php index f8a779161..7327dc14b 100644 --- a/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php +++ b/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php @@ -43,7 +43,7 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora * @throws PHPExcel_Exception */ protected function _storeData() { - if ($this->_currentCellIsDirty) { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject)); diff --git a/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php b/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php index 9825cabf9..12c9b589d 100644 --- a/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php +++ b/Classes/PHPExcel/CachedObjectStorage/MemorySerialized.php @@ -43,7 +43,7 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec * @throws PHPExcel_Exception */ protected function _storeData() { - if ($this->_currentCellIsDirty) { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject); diff --git a/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php b/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php index 61fb41603..9078b3757 100644 --- a/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php +++ b/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php @@ -57,7 +57,7 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_ * @throws PHPExcel_Exception */ protected function _storeData() { - if ($this->_currentCellIsDirty) { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); fseek($this->_fileHandle,0,SEEK_END); diff --git a/Classes/PHPExcel/CachedObjectStorage/SQLite.php b/Classes/PHPExcel/CachedObjectStorage/SQLite.php index 1b0221ee1..3585f7599 100644 --- a/Classes/PHPExcel/CachedObjectStorage/SQLite.php +++ b/Classes/PHPExcel/CachedObjectStorage/SQLite.php @@ -57,7 +57,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C * @throws PHPExcel_Exception */ protected function _storeData() { - if ($this->_currentCellIsDirty) { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')")) diff --git a/Classes/PHPExcel/CachedObjectStorage/SQLite3.php b/Classes/PHPExcel/CachedObjectStorage/SQLite3.php index 7e6924770..187b83f70 100644 --- a/Classes/PHPExcel/CachedObjectStorage/SQLite3.php +++ b/Classes/PHPExcel/CachedObjectStorage/SQLite3.php @@ -85,7 +85,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_ * @throws PHPExcel_Exception */ protected function _storeData() { - if ($this->_currentCellIsDirty) { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT); diff --git a/Classes/PHPExcel/CachedObjectStorage/Wincache.php b/Classes/PHPExcel/CachedObjectStorage/Wincache.php index af31eb7d4..c4fbd371c 100644 --- a/Classes/PHPExcel/CachedObjectStorage/Wincache.php +++ b/Classes/PHPExcel/CachedObjectStorage/Wincache.php @@ -58,7 +58,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage * @throws PHPExcel_Exception */ protected function _storeData() { - if ($this->_currentCellIsDirty) { + if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) { $this->_currentObject->detach(); $obj = serialize($this->_currentObject); diff --git a/changelog.txt b/changelog.txt index db0bc146d..9c8841422 100644 --- a/changelog.txt +++ b/changelog.txt @@ -41,6 +41,7 @@ Fixed in develop branch for release v1.8.0: - Bugfix: (PowerKiKi) Work Item GH-270/GH-31 - Binary comparison of strings are case insensitive - Bugfix: (MBaker) Work Item GH-275 - Insert New Row/Column Before is not correctly updating formula references - Bugfix: (MBaker) Work Item GH-257 - Passing an array of cells to _generateRow() in the HTML/PDF Writer causes caching problems with last cell in the range +- Bugfix: (MBaker) Work Item GH-193 - Fix to empty worksheet garbage collection when using cell caching - Feature: (amerov) - Implementation of the Excel HLOOKUP() function - Feature: (MBaker) - Added "Quote Prefix" to style settings (Excel2007 Reader and Writer only) - Feature: (MBaker) - Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer