From fd689dbe1c164733dfc9185e385c8bd50fe548b7 Mon Sep 17 00:00:00 2001 From: Basil Suter Date: Mon, 1 Apr 2019 11:00:32 +0200 Subject: [PATCH] use parent unlink class for file helper --- core/helpers/FileHelper.php | 10 ++++++---- tests/core/helpers/FileHelperTest.php | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/helpers/FileHelper.php b/core/helpers/FileHelper.php index 3cb07234b..ceaff95d9 100644 --- a/core/helpers/FileHelper.php +++ b/core/helpers/FileHelper.php @@ -198,10 +198,12 @@ public static function getFileContent($fileName) */ public static function unlink($file) { - // default unlink - if (@unlink($file)) { - return true; - } + // no errors should be thrown, return false instead. + try { + if (parent::unlink($file)) { + return true; + } + } catch (\Exception $e) {} // try to force symlinks if (is_link($file)) { diff --git a/tests/core/helpers/FileHelperTest.php b/tests/core/helpers/FileHelperTest.php index d67763f24..451fdf647 100644 --- a/tests/core/helpers/FileHelperTest.php +++ b/tests/core/helpers/FileHelperTest.php @@ -75,6 +75,11 @@ public function testGetFileContent() $this->assertFalse(FileHelper::getFileContent('doesNotExist.txt')); } + + public function testUnlink() + { + $this->assertFalse(FileHelper::unlink('doesnotexsts.jpg')); + } public function testClassInfo() {