Remove file_id from the cloned object before destruction

This prevents the cloned object from removing temporary files
owned by the original object during cleanup, potentially
leaving some that were created during the transaction,
but these should be cleaned with the original object

Fixes #205
This commit is contained in:
Jakub Jelen 2020-04-10 17:07:29 +02:00
parent 485956db63
commit 0727b9598f

View File

@ -7774,7 +7774,7 @@ class TCPDF {
if (isset(self::$cleaned_ids[$this->file_id])) {
$destroyall = false;
}
if ($destroyall AND !$preserve_objcopy) {
if ($destroyall AND !$preserve_objcopy && isset($this->file_id)) {
self::$cleaned_ids[$this->file_id] = true;
// remove all temporary files
if ($handle = @opendir(K_PATH_CACHE)) {
@ -21717,6 +21717,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
public function commitTransaction() {
if (isset($this->objcopy)) {
$this->objcopy->_destroy(true, true);
/* The unique file_id should not be used during cleanup again */
$this->objcopy->file_id = NULL;
unset($this->objcopy);
}
}
@ -21730,14 +21732,22 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
*/
public function rollbackTransaction($self=false) {
if (isset($this->objcopy)) {
$objcopy = $this->objcopy;
$this->_destroy(true, true);
if ($self) {
$objvars = get_object_vars($this->objcopy);
$objvars = get_object_vars($objcopy);
foreach ($objvars as $key => $value) {
$this->$key = $value;
}
$objcopy->_destroy(true, true);
/* The unique file_id should not be used during cleanup again */
$objcopy->file_id = NULL;
unset($objcopy);
return $this;
}
return $this->objcopy;
/* The unique file_id should not be used during cleanup again */
$this->file_id = NULL;
return $objcopy;
}
return $this;
}