1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
From 7dbdfa405123c2fbca4864d87a143f7977403767 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vojta=20Mat=C4=9Bjka?= <woytam@users.noreply.github.com>
Date: Sun, 20 Oct 2019 15:30:04 +0200
Subject: [PATCH] Problem with imagekeys undefined or unlinked
PR #136 removed problem with undefined `$imagekeys`, but the solution skipped cleaning files in `$imagekeys`.
The problem about this is that `_destroy` function is called 3 times (from `Close` function, as `shutdown_handler` and from `__desctruct` function). Only first time is called as `destroyall == false`, but unset `$imagekeys`. My solution is to preserve `$imagekeys` to be cleaned by call with `$imagekeys == true`.
---
tcpdf.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tcpdf.php b/tcpdf.php
index 0ee30bc0..a38edfcc 100644
--- a/tcpdf.php
+++ b/tcpdf.php
@@ -7796,10 +7796,8 @@ public function _destroy($destroyall=false, $preserve_objcopy=false) {
}
closedir($handle);
}
- if (isset($this->imagekeys)) {
- foreach($this->imagekeys as $file) {
- unlink($file);
- }
+ foreach($this->imagekeys as $file) {
+ unlink($file);
}
}
$preserve = array(
@@ -7809,6 +7807,7 @@ public function _destroy($destroyall=false, $preserve_objcopy=false) {
'bufferlen',
'buffer',
'cached_files',
+ 'imagekeys',
'sign',
'signature_data',
'signature_max_length',
|