-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Phase out deprecated $php_errormsg variable and track_errors use in HTTP and Language packages
#17856
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
Conversation
libraries/src/Language/Language.php
Outdated
| $php_errormsg = null; | ||
|
|
||
| $trackErrors = ini_get('track_errors'); | ||
| ini_set('track_errors', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do not you remove these lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want it to track errors regardless of PHP config while in debug mode. So this ensures the setting is enabled then reset to what it was previously at the end of the process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nevermind. This is the deprecated thing. 🤦♂️
Need more coffee.
| */ | ||
| protected function parse($filename) | ||
| { | ||
| // Capture hidden PHP errors from the parsing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this comment is no longer applicable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is still applicable. When debug mode is enabled we are still setting error reporting to maximum basically so that parse errors are exposed, then resetting error reporting to the configured value.
| { | ||
| if (!$php_errormsg) | ||
| $lastError = error_get_last(); | ||
| $message = sprintf('Could not connect to resource: %s', $uri, $err, $errno); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move the initialization of $message below to the else statement? The same on the second file too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't an else, unless you're saying to make it an if/else statement...
|
I suggest to use For test I removed the first double quote character from com_content language file. Before patch: After patch: |
How reliable is the polyfill for |
|
Or you can remember the previous error message before line |
|
This is my test. $ php -a
Interactive mode enabled
php > echo $e;
PHP Notice: Undefined variable: e in php shell code on line 1
php > $handler = function() { return false;};
php > set_error_handler($handler);
php > @trigger_error('');
php > restore_error_handler();
php > print_r(error_get_last());
Array
(
[type] => 1024
[message] =>
[file] => php shell code
[line] => 1
)
php > echo phpversion();
7.1.12-3+ubuntu16.04.1+deb.sury.org+1 |
|
Eh, maybe later. |
Partial Pull Request for Issue #16584
Summary of Changes
PHP 7.2 deprecates the
track_errorsINI configuration and the scoped$php_errormsgvariable in favor of using theerror_get_last()function for retrieving error data, and at PHP 7.0 usingerror_clear_last()to clear any errors (to my knowledge we aren't doing anything in core requiring the latter at the moment).This PR phases out this deprecated functionality for the HTTP and Language packages.
Testing Instructions
The packages should still function normally, including error handling (easiest way to test error handling is enable debug mode and language debug and break one of the language files with a parsing error).