Skip to content

Commit 62444d2

Browse files
authored
Merge pull request #2176 from maartendekeizer/cleanuptempfile
[TemplateProcessor] Clean up temp files
2 parents 969448f + e9cd17d commit 62444d2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/PhpWord/TemplateProcessor.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ public function __construct($documentTemplate)
131131
$this->tempDocumentContentTypes = $this->zipClass->getFromName($this->getDocumentContentTypesName());
132132
}
133133

134+
public function __destruct()
135+
{
136+
// if the temp file still exists, remove it when running destruct
137+
if ($this->tempDocumentFilename && file_exists($this->tempDocumentFilename) && is_writable($this->tempDocumentFilename)) {
138+
@unlink($this->tempDocumentFilename);
139+
}
140+
}
141+
134142
/**
135143
* Expose zip class.
136144
*

0 commit comments

Comments
 (0)