Optimize error handling
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 52/100
Research direction
Start at Respect\Rest\Request::prepareForErrorForwards() and inspect how errors are collected for error side routes. Verify that errors suppressed with @ are not forwarded while unsuppressed errors still are; the issue's proposed handler shows the intended check.
Written by the indexing model from the issue text.
Description
Errors/warnings of functions which are suppressed with "@" (for example @array_keys_exist('test', new \stdClass()) in PHP 7.4) are not ignored by the error handling. In Respect\Rest\Request::prepareForErrorForwards() all errors are collected and later forwarded to the error route. Problem is that the information if a error/warning was suppressed with "@" isn't present in the error route anymore. It only can be checked in the PHP error handler callback through error_reporting() === 0. So this check needs to be done in Respect\Rest\Request::prepareForErrorForwards() before adding a error to the error side route. Method would look like this:
protected function prepareForErrorForwards()
{
foreach ($this->route->sideRoutes as $sideRoute) {
if ($sideRoute instanceof Routes\Error) {
return set_error_handler(
function () use ($sideRoute) {
// Don't do anything if error_reporting is disabled by an @ sign
if (error_reporting() !== 0) {
$sideRoute->errors[] = func_get_args();
}
}
);
}
}
}
I can provide a pull request, too.
- Dominant language
- PHP
- Stars
- 605
- Forks
- 100
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Respect/Rest
-
Project Status Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
-
New Roadmap Open
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Similar issues
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Automattic/safe-publish#594 ·
-
needs-triage Platform(Default)
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
HttpClient
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
symfony/symfony-docs#23092 ·
-
sync-en
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
sync-en
Difficulty 1/5 Under an hour Newbie friendliness 95/100