From 7e7c5cb40bbd1e558bbabc407102c8b2937fc56c Mon Sep 17 00:00:00 2001 From: mcdruid Date: Tue, 3 Dec 2024 22:46:21 +0000 Subject: [PATCH 1/2] check temp path before deleting files in destructor --- src/InterventionBackend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/InterventionBackend.php b/src/InterventionBackend.php index a6644560..7746e650 100644 --- a/src/InterventionBackend.php +++ b/src/InterventionBackend.php @@ -815,7 +815,7 @@ public function __destruct() $this->image->destroy(); } // remove our temp file if it exists - if (file_exists($this->getTempPath() ?? '')) { + if ((strpos(basename($this->getTempPath()), 'interventionimage_') === 0) && file_exists($this->getTempPath() ?? '')) { unlink($this->getTempPath() ?? ''); } } From 16006f5578cb6b5ba68a31021bac5b2c7d85eb1e Mon Sep 17 00:00:00 2001 From: mcdruid Date: Wed, 4 Dec 2024 08:52:31 +0000 Subject: [PATCH 2/2] silverstripe requires PHP8 so we can use str_starts_with --- src/InterventionBackend.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/InterventionBackend.php b/src/InterventionBackend.php index 7746e650..df79a048 100644 --- a/src/InterventionBackend.php +++ b/src/InterventionBackend.php @@ -815,7 +815,7 @@ public function __destruct() $this->image->destroy(); } // remove our temp file if it exists - if ((strpos(basename($this->getTempPath()), 'interventionimage_') === 0) && file_exists($this->getTempPath() ?? '')) { + if (str_starts_with(basename($this->getTempPath()), 'interventionimage_') && file_exists($this->getTempPath() ?? '')) { unlink($this->getTempPath() ?? ''); } }