mirror of
https://github.com/tecnickcom/TCPDF.git
synced 2025-03-21 14:39:40 +01:00
Fix performance issue of cloned instances
I noted a performance issue using TCPDF when doing a lot of clones of the instance, it's caused by the destructor being called multiple times to cleanup things that already have been cleaned This checks if the files have already been cleaned before redoing an expensive filesystem operation again (glob)
This commit is contained in:
parent
756908329d
commit
e91887e463
@ -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,7 +7750,11 @@ 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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user