PHP Version
8.1
CodeIgniter4 Version
latest develop (4.2.x)
CodeIgniter4 Installation Method
Git
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
No response
What happened?
It seems when the registered shutdown handler is called when there is a fatal error, it reduces the severity of the error to 0 (zero).
Steps to Reproduce
diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php
index 7f867e95f..7568a9619 100644
--- a/app/Controllers/Home.php
+++ b/app/Controllers/Home.php
@@ -6,6 +6,10 @@ class Home extends BaseController
{
public function index()
{
+ foreach (range(1, 1e9) as $_) {
+ new \ReflectionClass($this);
+ }
+
return view('welcome_message');
}
}
diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php
index 9994aa7a0..2ec4468c7 100644
--- a/system/Debug/Exceptions.php
+++ b/system/Debug/Exceptions.php
@@ -135,6 +135,7 @@ class Exceptions
}
}
+ var_dump($exception);
$this->render($exception, $statusCode);
exit($exitCode);
@@ -174,6 +175,8 @@ class Exceptions
return;
}
+ var_dump($error);
+
['type' => $type, 'message' => $message, 'file' => $file, 'line' => $line] = $error;
if (in_array($type, [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE], true)) {
The error here is E_ERROR with value of 1. However, based on the dumps:

The type key from the $error (which is 1) gets turned into $severity of 0.
Expected Output
The type (or severity) of the error is preserved when converted into an \ErrorException.
Anything else?
It seems the easy fix is to swap the 0 and $type when instantiating ErrorException.
diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php
index 9994aa7a0..4a9220223 100644
--- a/system/Debug/Exceptions.php
+++ b/system/Debug/Exceptions.php
@@ -135,6 +135,7 @@ class Exceptions
}
}
+ var_dump($exception);
$this->render($exception, $statusCode);
exit($exitCode);
@@ -174,10 +175,12 @@ class Exceptions
return;
}
['type' => $type, 'message' => $message, 'file' => $file, 'line' => $line] = $error;
if (in_array($type, [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE], true)) {
- $this->exceptionHandler(new ErrorException($message, $type, 0, $file, $line));
+ $this->exceptionHandler(new ErrorException($message, 0, $type, $file, $line));
}
}
but I'm not sure of BC concerns.
PHP Version
8.1
CodeIgniter4 Version
latest develop (4.2.x)
CodeIgniter4 Installation Method
Git
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
No response
What happened?
It seems when the registered shutdown handler is called when there is a fatal error, it reduces the severity of the error to
0(zero).Steps to Reproduce
The error here is

E_ERRORwith value of1. However, based on the dumps:The
typekey from the$error(which is1) gets turned into$severityof0.Expected Output
The type (or severity) of the error is preserved when converted into an
\ErrorException.Anything else?
It seems the easy fix is to swap the
0and$typewhen instantiatingErrorException.but I'm not sure of BC concerns.