Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignoring errors suppressed by @ #1500

Merged
merged 3 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}