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

Error control operator may trigger a fatal error with PHP 8.0 #2066

Closed
benoitchantre opened this issue Jun 22, 2022 · 3 comments
Closed

Error control operator may trigger a fatal error with PHP 8.0 #2066

benoitchantre opened this issue Jun 22, 2022 · 3 comments

Comments

@benoitchantre
Copy link

Is your feature request related to a problem?

In many plugins, I have noticed an issue with the error control operator @ used with set_time_limit().

The error happens when PHP 8.0 is used and when set_time_limit() has been disabled on the server.

Prior to PHP 8.0.0, it was possible for the @ operator to disable critical errors that will terminate script execution. For example, prepending @ to a call of a function which did not exist, by being unavailable or mistyped, would cause the script to terminate with no indication as to why.
https://www.php.net/manual/en/language.operators.errorcontrol.php

Describe the solution you'd like

I think the sniffs should look for the error operator and trigger a warning.

Additional context (optional)

  • PHP 8.0
  • any disabled function used with the error operator
@jrfnl
Copy link
Member

jrfnl commented Jun 22, 2022

@benoitchantre It already does. The WordPress.PHP.NoSilencedErrors sniff does exactly that and is included in both the WordPress-Core as well as the WordPress-Extra rulesets.

For Core, the sniff respects a list of PHP native functions for which to allow the @ operator (which doesn't include the set_time_limit() function). For Extra that list is disregarded by default and a warning will be thrown for all uses of @.

@jrfnl jrfnl closed this as completed Jun 22, 2022
@benoitchantre
Copy link
Author

@jrfnl Thank you for the detailed answer.

@jrfnl
Copy link
Member

jrfnl commented Jun 22, 2022

@benoitchantre Happy to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants