Bugfix: Work item 16643 - Bug In Cache System (cell reference when throwing caching errors)

General: Work item 16643 - Add file directory as a cache option for cache_to_discISAM

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@82024 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2011-10-26 16:16:43 +00:00
parent efc066c233
commit 77cd4ac9aa
7 changed files with 24 additions and 16 deletions

View File

@ -46,7 +46,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
$this->__destruct();
throw new Exception('Failed to store cell '.$cellID.' in APC');
throw new Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
}
$this->_currentCellIsDirty = false;
}
@ -94,7 +94,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
if ($success === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry '.$cellID.' no longer exists in APC');
throw new Exception('Cell entry '.$pCoord.' no longer exists in APC');
}
return true;
}
@ -121,7 +121,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
if ($obj === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry '.$cellID.' no longer exists in APC');
throw new Exception('Cell entry '.$pCoord.' no longer exists in APC');
}
} else {
// Return null if requested entry doesn't exist in cache

View File

@ -38,6 +38,8 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
private $_fileName = null;
private $_fileHandle = null;
private $_cacheDirectory = NULL;
private function _storeData() {
if ($this->_currentCellIsDirty) {
@ -116,7 +118,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->_getUniqueID();
$newFileName = PHPExcel_Shared_File::sys_get_temp_dir().'/PHPExcel.'.$baseUnique.'.cache';
$newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
// Copy the existing cell cache file
copy ($this->_fileName,$newFileName);
$this->_fileName = $newFileName;
@ -140,11 +142,15 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
} // function unsetWorksheetCells()
public function __construct(PHPExcel_Worksheet $parent) {
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))
? $arguments['dir']
: PHPExcel_Shared_File::sys_get_temp_dir();
parent::__construct($parent);
if (is_null($this->_fileHandle)) {
$baseUnique = $this->_getUniqueID();
$this->_fileName = PHPExcel_Shared_File::sys_get_temp_dir().'/PHPExcel.'.$baseUnique.'.cache';
$this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
$this->_fileHandle = fopen($this->_fileName,'a+');
}
} // function __construct()

View File

@ -50,7 +50,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
$this->__destruct();
throw new Exception('Failed to store cell '.$cellID.' in MemCache');
throw new Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');
}
}
$this->_currentCellIsDirty = false;
@ -99,7 +99,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
if ($success === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache');
throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
}
return true;
}
@ -126,7 +126,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache');
throw new Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
}
} else {
// Return null if requested entry doesn't exist in cache

View File

@ -48,12 +48,12 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
if (!wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
$this->__destruct();
throw new Exception('Failed to store cell '.$cellID.' in WinCache');
throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
}
} else {
if (!wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime)) {
$this->__destruct();
throw new Exception('Failed to store cell '.$cellID.' in WinCache');
throw new Exception('Failed to store cell '.$this->_currentObjectID.' in WinCache');
}
}
$this->_currentCellIsDirty = false;
@ -103,7 +103,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
if ($success === false) {
// Entry no longer exists in Wincache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry '.$cellID.' no longer exists in WinCache');
throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
}
return true;
}
@ -132,7 +132,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
if ($success === false) {
// Entry no longer exists in WinCache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry '.$cellID.' no longer exists in WinCache');
throw new Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
}
} else {
// Return null if requested entry doesn't exist in cache

View File

@ -37,7 +37,7 @@ class PHPExcel_CachedObjectStorageFactory {
),
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
),
self::cache_to_discISAM => array(
self::cache_to_discISAM => array( 'dir' => NULL
),
self::cache_to_apc => array( 'cacheTime' => 600
),

View File

@ -39,8 +39,10 @@ Fixed in SVN:
- Bugfix: (MBaker) Work item 16246 - reader/CSV fails on this file
auto_detect_line_endings now set in CSV reader
- Bugfix: (MBaker) Work item 16212 - $arguments improperly used in CachedObjectStorage/PHPTemp.php
- General: (MBaker) Work item 15405 - Two easy to fix Issues concerning PHPExcel_Token_Stack (l10n/UC)
- General: (MBaker) Work item 15461 - Locale file paths not fit for windows
- Bugfix: (MBaker) Work item 16643 - Bug In Cache System (cell reference when throwing caching errors)
- General: (MBaker) Work item 15405 - Two easy to fix Issues concerning PHPExcel_Token_Stack (l10n/UC)
- General: (MBaker) Work item 15461 - Locale file paths not fit for windows
- General: (MBaker) Work item 16643 - Add file directory as a cache option for cache_to_discISAM
2011-02-27 (v1.7.6):