Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tweak error/exception handler registration#58372

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedSep 24, 2024
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#53812,Fix#46692
LicenseMIT

This should allow removing the custom bootstrap file from#58370 /cc@xabbuh

The change on FrameworkBundle leads to a tweaked behavior: we don't override the previous error handler in case it's not the Symfony one. This shouldn't change anything in practice since the error handler is already registered by the runtime component.

The rest is closer to bug fixes.

derrabus reacted with rocket emoji
@xabbuh
Copy link
Member

@derrabus FYI as you used the same workaround for Twig

derrabus reacted with eyes emoji

@nicolas-grekas
Copy link
MemberAuthor

I'm wondering about merging this in 6.4 🤔

@nicolas-grekas
Copy link
MemberAuthor

Rebased on 6.4

Comment on lines 107 to 108
$exceptionHandler =set_exception_handler('var_dump');
restore_exception_handler();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We need a PHP RFC to getget_exception_handler() 👀

nicolas-grekas reacted with rocket emoji
@derrabus
Copy link
Member

Thank you. I'm a bit reluctant to merge this as a bugfix because of the change in behavior though.

@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.2Sep 25, 2024
@nicolas-grekasnicolas-grekas changed the base branch from6.4 to7.2September 25, 2024 08:08
@derrabus
Copy link
Member

Then again, not having this change on 6.4 means we need to keep those bootstrap files for low-deps testing. Difficult decision. 🙈

@nicolas-grekasnicolas-grekas changed the base branch from7.2 to5.4September 25, 2024 08:42
@nicolas-grekasnicolas-grekas modified the milestones:7.2,5.4Sep 25, 2024
@nicolas-grekasnicolas-grekasforce-pushed thetweak-error-handler-reg branch 2 times, most recently from2775afb to97c08adCompareSeptember 25, 2024 09:15
Copy link
MemberAuthor

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I rebased this on 5.4 and did a fix on symfony/runtime so that we have simpler setup of the error-handler register.
This should unlock moving to phpunit11 (deps=low included)

publicfunctionboot()
{
ErrorHandler::register(null,false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'),true);
if (class_exists(SymfonyRuntime::class)) {
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

When symfony/runtime is installed, we assume it will register the ErrorHandler when appropriate.
That's not the case right now, but this PR fixes it.

$handler =set_error_handler('var_dump');
restore_error_handler();
}else {
$handler = [ErrorHandler::register(null,false)];
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

When symfony/runtime is not found, the index.php file registers ErrorHandler only in debug mode, so we need to register it to not break prod mode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

shouldn't we check whether it is already registered ? Maybe some devs have changed the index.php file.

And wouldn't this still cause issues with PHPUnit 11 then when booting a kernel during tests ?

Copy link
MemberAuthor

@nicolas-grekasnicolas-grekasSep 25, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thefalse argument is here to skip registering ifErrorHandler is already registered.
This line preserves the current behavior when symfoy/runtime isn't installed so I wouldn't add more logic here.

"symfony/mime":"<4.4",
"symfony/property-info":"<4.4",
"symfony/property-access":"<5.3",
"symfony/runtime":"<5.4.45|>=6.0,<6.4.13|>=7.0,7.1.6",
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

ensures that we symfony/runtime is installed, it's a version that always registers ErrorHandler

$_SERVER[$debugKey] =$_ENV[$debugKey] ='0';
}

if (false !==$errorHandler = ($options['error_handler'] ?? BasicErrorHandler::class)) {
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

untightening the error_handler option from the debug one

@xabbuh
Copy link
Member

The test failures are related, aren't they?

@nicolas-grekasnicolas-grekasforce-pushed thetweak-error-handler-reg branch 2 times, most recently from704e252 to6d0b67dCompareSeptember 25, 2024 13:30
@nicolas-grekas
Copy link
MemberAuthor

The test failures are related, aren't they?

yes they are, this line is deprecated indeed when $debug = false:ini_set('assert.active', $debug);

PR updated

@nicolas-grekasnicolas-grekas merged commitde1a6ac intosymfony:5.4Sep 25, 2024
11 of 12 checks passed
@nicolas-grekasnicolas-grekas deleted the tweak-error-handler-reg branchOctober 24, 2024 14:18
This was referencedOct 27, 2024
}

if (0 <=\ini_get('zend.assertions')) {
ini_set('zend.assertions', (int)$debug);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@nicolas-grekas why are you disabling assertions in non-debug mode ? We are relying on assertions in production mode and this change breaks our application.

kin29 reacted with thumbs up emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@lyrixxlyrixxlyrixx left review comments

@stofstofstof approved these changes

@derrabusderrabusderrabus approved these changes

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

@ycerutoycerutoAwaiting requested review from yceruto

@dunglasdunglasAwaiting requested review from dunglas

@OskarStarkOskarStarkAwaiting requested review from OskarStark

@jderussejderusseAwaiting requested review from jderusse

@xabbuhxabbuhAwaiting requested review from xabbuh

+1 more reviewer

@NoiseByNorthwestNoiseByNorthwestNoiseByNorthwest left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

[Framework bundle] Cleanup error and exception handlers on Kernel shutdown

7 participants

@nicolas-grekas@xabbuh@derrabus@lyrixx@stof@NoiseByNorthwest@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp