From 210ff2239f1e0f137703b9525d677c36a84dcce2 Mon Sep 17 00:00:00 2001 From: Roy Van Ginneken Date: Mon, 28 Sep 2020 09:51:01 +0200 Subject: [PATCH] Make sure we don\t check the same for existing multiple times --- tcpdf.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tcpdf.php b/tcpdf.php index a09ad4c..2d09a80 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -6885,7 +6885,7 @@ class TCPDF { $exurl = $file; } // check if file exist and it is valid - if (!@TCPDF_STATIC::file_exists($file)) { + if (!@$this->fileExists($file)) { return false; } if (($imsize = @getimagesize($file)) === FALSE) { @@ -24579,6 +24579,11 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: // --- END SVG METHODS ----------------------------------------------------- + /** + * Keeps files in memory, so it doesn't need to downloaded everytime in a loop + * @param string $file + * @return string + */ protected function getCachedFileContents($file) { if (!isset($this->fileContentCache[$file])) { @@ -24587,6 +24592,20 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: return $this->fileContentCache[$file]; } + /** + * Make use of the file content cache, to avoid a lot of calls to an external server to see if a file exists + * @param string $file + * @return bool + */ + protected function fileExists($file) + { + if (isset($this->fileContentCache[$file])) { + return true; + } + + return TCPDF_STATIC::file_exists($file); + } + } // END OF TCPDF CLASS //============================================================+