Skip to content

Commit

Permalink
Merge pull request #1500 from samsonasik/500
Browse files Browse the repository at this point in the history
Ignoring errors suppressed by @
  • Loading branch information
lonnieezell authored Nov 19, 2018
2 parents 4594b8e + 7f34032 commit 69353cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/Files/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
15 changes: 15 additions & 0 deletions tests/system/CodeIgniterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<h1>Welcome to CodeIgniter</h1>', $output);
}
}

0 comments on commit 69353cb

Please sign in to comment.