Make sure we don\t check the same for existing multiple times

This commit is contained in:
Roy Van Ginneken 2020-09-28 09:51:01 +02:00
parent 5a3b44c729
commit 210ff2239f

View File

@ -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
//============================================================+