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

[ErrorHandler] Make assert() silent when assert.quiet_eval=1 #35639

Closed
wants to merge 1 commit into from

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

Working around https://bugs.php.net/75769
/cc @nikic FYI :)

@nikic
Copy link
Contributor

nikic commented Feb 7, 2020

Please don't. assert.quiet_eval is meaningless for non-string asserts and removed in PHP 8.

@nicolas-grekas
Copy link
Member Author

It would be really useful to make it work in PHP8! The use case is the following: turn assert() "on" in prod, but in a silenced mode only. Instead of disrupting execution, this would trigger warnings with error_reporting() set to zero. Then, userland error handlers would catch those and log them, allowing to debug issues with assert() on prod systems. I don't know the plan for PHP8, but please don't make assert() always throw!

@nikic
Copy link
Contributor

nikic commented Feb 7, 2020

@nicolas-grekas I think you are mixing up assert.exception/assert.warning with assert.quiet_eval. quiet_eval only affects errors generated during evaluation of the assert itself, it does not affect how an assertion failure is reported.

You may also want to look into ASSERT_CALLBACK, which is probably a more convenient way to add custom assert handling than to listen for warnings in an error handler.

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Feb 7, 2020

OK, I'll give it a 2nd look, thanks for the feedback. By any chance, do you have any hints about the plans for PHP 8 on this topic?

@nikic
Copy link
Contributor

nikic commented Feb 7, 2020

@nicolas-grekas Don't think there are any plans in that area (yet...) There was only some talk of making assert.exception=1 the default (instead of assert.warning=1).

@nicolas-grekas nicolas-grekas deleted the eh-assert branch February 7, 2020 22:39
@nicolas-grekas
Copy link
Member Author

Alternative proposal in #35645

@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants