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() {