From de0ae1af6192f822c04c92ad5ac5d3e61e72a6e5 Mon Sep 17 00:00:00 2001 From: Adrien Foulon <6115458+Tofandel@users.noreply.github.com> Date: Fri, 22 Mar 2019 13:13:31 +0100 Subject: [PATCH] Also change glob to readdir which performs better --- tcpdf.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tcpdf.php b/tcpdf.php index 3bba7b0..47d92d4 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -7756,9 +7756,13 @@ class TCPDF { 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(