From 31612d3e9508325416bbb5571293243d0a7ec74c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 18 Nov 2018 19:33:57 +0700 Subject: [PATCH 1/3] Ignoring errors suppressed by @ --- system/Debug/Exceptions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index 5f0839f84501..b87fbd7cd0a2 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -174,6 +174,10 @@ public function exceptionHandler(\Throwable $exception) */ public function errorHandler(int $severity, string $message, string $file = null, int $line = null, $context = null) { + if (! (\error_reporting() & $severity)) { + return; + } + // Convert it to an exception and pass it along. throw new \ErrorException($message, 0, $severity, $file, $line); } From 190df9d86ecb58d1a5557f6355d133c7f0c6d2e9 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 18 Nov 2018 20:17:26 +0700 Subject: [PATCH 2/3] fix try catch move_uploaded_file to not use @ --- system/HTTP/Files/UploadedFile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/HTTP/Files/UploadedFile.php b/system/HTTP/Files/UploadedFile.php index 352ccec4344c..71b4296e42cf 100644 --- a/system/HTTP/Files/UploadedFile.php +++ b/system/HTTP/Files/UploadedFile.php @@ -172,7 +172,7 @@ public function move(string $targetPath, string $name = null, bool $overwrite = try { - @move_uploaded_file($this->path, $destination); + move_uploaded_file($this->path, $destination); } catch (\Exception $e) { From 7f34032981074757f8047f4078b370df07ee302e Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 18 Nov 2018 20:36:36 +0700 Subject: [PATCH 3/3] test for ignoring error suppressed by @ --- tests/system/CodeIgniterTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php index ddaec66b331f..b2eb0a6a1d64 100644 --- a/tests/system/CodeIgniterTest.php +++ b/tests/system/CodeIgniterTest.php @@ -258,4 +258,19 @@ public function testTransfersCorrectHTTPVersion() $this->assertEquals(2, $response->getProtocolVersion()); } + public function testIgnoringErrorSuppressedByAt() + { + $_SERVER['argv'] = [ + 'index.php', + '/', + ]; + $_SERVER['argc'] = 2; + + ob_start(); + @unlink('inexistent-file'); + $this->codeigniter->useSafeOutput(true)->run(); + $output = ob_get_clean(); + + $this->assertContains('

Welcome to CodeIgniter

', $output); + } }