From 23f0333f0484401191c2af9939464b4e9dcde3bd Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Wed, 6 Nov 2019 22:08:51 +0100 Subject: [PATCH] Add '@' to various IO function to suppress OS exception - now QFQ will report customized messages. --- extension/Classes/Core/Helper/HelperFile.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extension/Classes/Core/Helper/HelperFile.php b/extension/Classes/Core/Helper/HelperFile.php index 78c7103c7..bc0cb0cce 100644 --- a/extension/Classes/Core/Helper/HelperFile.php +++ b/extension/Classes/Core/Helper/HelperFile.php @@ -247,9 +247,9 @@ class HelperFile { public static function chmod($pathFileName, $mode = false) { if ($mode !== false) { - if (false === chmod($pathFileName, $mode)) { + if (false === @chmod($pathFileName, $mode)) { throw new \UserFormException( - json_encode([ERROR_MESSAGE_TO_USER => 'Failed: chmod', ERROR_MESSAGE_TO_DEVELOPER => "Failed: chmod $mode '$pathFileName'"]), + json_encode([ERROR_MESSAGE_TO_USER => 'Failed: chmod', ERROR_MESSAGE_TO_DEVELOPER => self::errorGetLastAsString()]), ERROR_IO_CHMOD); } } @@ -277,7 +277,7 @@ class HelperFile { */ public static function chdir($cwd) { - if (false === chdir($cwd)) { + if (false === @chdir($cwd)) { $msg = self::errorGetLastAsString() . " - chdir($cwd)"; throw new \UserFormException(json_encode([ERROR_MESSAGE_TO_USER => 'chdir failed', ERROR_MESSAGE_TO_DEVELOPER => $msg]), ERROR_IO_CHDIR); } @@ -300,7 +300,7 @@ class HelperFile { Logger::logMessageWithPrefix("Unlink: $filename", $logFilename); } - if (false === unlink($filename)) { + if (false === @unlink($filename)) { $msg = self::errorGetLastAsString() . " - unlink($filename)"; throw new \UserFormException(json_encode([ERROR_MESSAGE_TO_USER => 'unlink failed', ERROR_MESSAGE_TO_DEVELOPER => $msg]), ERROR_IO_UNLINK); } @@ -317,7 +317,7 @@ class HelperFile { */ public static function rmdir($tempDir) { - if (false === rmdir($tempDir)) { + if (false === @rmdir($tempDir)) { $msg = self::errorGetLastAsString() . " - rmdir($tempDir)"; throw new \UserFormException(json_encode([ERROR_MESSAGE_TO_USER => 'rmdir failed', ERROR_MESSAGE_TO_DEVELOPER => $msg]), ERROR_IO_RMDIR); } @@ -335,7 +335,7 @@ class HelperFile { */ public static function rename($oldname, $newname) { - if (false === rename($oldname, $newname)) { + if (false === @rename($oldname, $newname)) { $msg = self::errorGetLastAsString() . " - rename($oldname ,$newname)"; throw new \UserFormException(json_encode([ERROR_MESSAGE_TO_USER => 'unlink failed', ERROR_MESSAGE_TO_DEVELOPER => $msg]), ERROR_IO_RENAME); } @@ -358,7 +358,7 @@ class HelperFile { touch($dest); } - if (false === copy($source, $dest)) { + if (false === @copy($source, $dest)) { if (!is_readable($source)) { throw new \UserFormException(json_encode([ERROR_MESSAGE_TO_USER => 'copy failed', ERROR_MESSAGE_TO_DEVELOPER => "Can't read file '$source'"]), ERROR_IO_READ_FILE); -- GitLab