1
0
mirror of https://github.com/tecnickcom/TCPDF.git synced 2025-03-25 08:29:43 +01:00

Merge pull request from Tofandel/patch-1

Fix performance issue of cloned instances
This commit is contained in:
Nicola Asuni 2019-09-19 10:14:32 +01:00 committed by GitHub
commit 2b5fca36b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7737,6 +7737,7 @@ class TCPDF {
return '';
}
protected static $cleaned_ids = array();
/**
* Unset all class variables except the following critical variables.
* @param $destroyall (boolean) if true destroys all class variables, otherwise preserves critical variables.
@ -7749,11 +7750,19 @@ class TCPDF {
if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) {
mb_internal_encoding($this->internal_encoding);
}
if (isset(self::$cleaned_ids[$this->file_id])) {
$destroyall = false;
}
if ($destroyall AND !$preserve_objcopy) {
self::$cleaned_ids[$this->file_id] = true;
// remove all temporary files
$tmpfiles = glob(K_PATH_CACHE.'__tcpdf_'.$this->file_id.'_*');
if (!empty($tmpfiles)) {
array_map('unlink', $tmpfiles);
if ($handle = opendir(K_PATH_CACHE)) {
while ( false !== ( $file_name = readdir( $handle ) ) ) {
if (strpos($file_name, '__tcpdf_'.$this->file_id.'_') === 0) {
unlink(K_PATH_CACHE.$file_name);
}
}
closedir($handle);
}
}
$preserve = array(