Fix overzealous cleanup of temporary files.
By cleaning up the temporary files on close() we can no longer
call getData() which breaks pretty much everything except when
not using temporary files at all.
This was introduced in 6f5b44cd6b
This commit is contained in:
parent
19c8cce3e0
commit
37e697b73f
|
|
@ -604,7 +604,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
|
|||
|
||||
$total_worksheets = count($this->_worksheets);
|
||||
for ($i = 0; $i < $total_worksheets; $i++) {
|
||||
while ($tmp = $this->_worksheets[$i]->getData()) {
|
||||
while ($tmp = $this->_worksheets[$i]->getData(true)) {
|
||||
$OLE->append($tmp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -652,16 +652,6 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
|||
$this->_storeDataValidity();
|
||||
}*/
|
||||
$this->_storeEof();
|
||||
|
||||
if ( $this->_tmp_file != '' ) {
|
||||
if ( $this->_filehandle ) {
|
||||
fclose($this->_filehandle);
|
||||
$this->_filehandle = '';
|
||||
}
|
||||
@unlink($this->_tmp_file);
|
||||
$this->_tmp_file = '';
|
||||
$this->_using_tmpfile = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -682,7 +672,7 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
|||
*
|
||||
* @return string The data
|
||||
*/
|
||||
public function getData()
|
||||
public function getData($cleanup = true)
|
||||
{
|
||||
$buffer = 4096;
|
||||
|
||||
|
|
@ -690,9 +680,8 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
|||
if (isset($this->_data)) {
|
||||
$tmp = $this->_data;
|
||||
unset($this->_data);
|
||||
$fh = $this->_filehandle;
|
||||
if ($this->_using_tmpfile) {
|
||||
fseek($fh, 0);
|
||||
fseek($this->_filehandle, 0);
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
|
@ -701,6 +690,19 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
|
|||
if ($tmp = fread($this->_filehandle, $buffer)) {
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// All data has now been read (both from memory & from file) so we
|
||||
// can now trash the file
|
||||
if ($cleanup) {
|
||||
if ( $this->_filehandle ) {
|
||||
fclose($this->_filehandle);
|
||||
$this->_filehandle = '';
|
||||
}
|
||||
@unlink($this->_tmp_file);
|
||||
$this->_tmp_file = '';
|
||||
$this->_using_tmpfile = false;
|
||||
$this->_datasize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// No data to return
|
||||
|
|
|
|||
Loading…
Reference in New Issue