Skip to content

Commit 020af6d

Browse files
authored
Merge pull request #6724 from paulbalandan/fix-error-handler-callback
Fix error handler callback
2 parents d5096b2 + b5d69d1 commit 020af6d

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

system/Debug/Exceptions.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,21 @@ public function exceptionHandler(Throwable $exception)
141141
}
142142

143143
/**
144-
* Even in PHP7, some errors make it through to the errorHandler, so
145-
* convert these to Exceptions and let the exception handler log it and
146-
* display it.
144+
* The callback to be registered to `set_error_handler()`.
147145
*
148-
* This seems to be primarily when a user triggers it with trigger_error().
146+
* @return bool
149147
*
150148
* @throws ErrorException
151149
*
152150
* @codeCoverageIgnore
153151
*/
154152
public function errorHandler(int $severity, string $message, ?string $file = null, ?int $line = null)
155153
{
156-
if (! (error_reporting() & $severity)) {
157-
return;
154+
if (error_reporting() & $severity) {
155+
throw new ErrorException($message, 0, $severity, $file, $line);
158156
}
159157

160-
throw new ErrorException($message, 0, $severity, $file, $line);
158+
return false; // return false to propagate the error to PHP standard error handler
161159
}
162160

163161
/**

user_guide_src/source/changelogs/v4.2.8.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ Bugs Fixed
3939
- Fixed a bug when the ``CodeIgniter\HTTP\IncomingRequest::getPostGet()`` and ``CodeIgniter\HTTP\IncomingRequest::getGetPost()`` methods didn't return values from the other stream when ``index`` was set to ``null``.
4040
- Fixed a bug when ``binds`` weren't cleaned properly when calling ``CodeIgniter\Database\Postgre::replace()`` multiple times in the context.
4141
- Fixed a bug when the ``CodeIgniter\Database\SQLSRV\PreparedQuery::_getResult()`` was returning the bool value instead of the resource.
42+
- Fixed a bug in the error handler where in cases the callback cannot process the error level it does not pass the error to PHP's standard error handler.
4243

4344
See the repo's `CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_ for a complete list of bugs fixed.

0 commit comments

Comments
 (0)