-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add ini_set() error reporting #2111
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
Raising E_WARNING for unrecognized ini options appears to make sense, but I would not add another ini option to configure this. :-) |
@cmb69 It could be
However, I don't mind much as user should be able to enable error reporting during development. It could be RFC vote option. |
This is a significant bc break. It's not uncommon at all to read an ini value that is defined only when some extension is enabled, without checking if the extension is loaded first. 👎 for that reason to me... |
@nicolas-grekas Having an option for each ini_set() and ini_get() could be good option. |
Looks at e.g. https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Debug/ExceptionHandler.php#L42 |
@nicolas-grekas Finding typo could be irritating. It should be easier than now. IMO. |
I'm -1 here for the same reason as @nicolas-grekas. It's super common to indiscriminately set ini settings for extensions that may or may not be loaded (or may or may not have that setting in that version). I don't think we currently even have a way to check if an ini setting exists upfront. |
@nikic Setting INI values could be security problem, so only raise warning for ini_set()? I'll make this a voting option. |
@@ -5304,6 +5304,9 @@ PHP_FUNCTION(ini_get) | |||
str = zend_ini_string(varname, (uint)varname_len, 0); | |||
|
|||
if (!str) { | |||
if (PG(report_ini_error)) { | |||
php_error_docref(NULL, E_WARNING, "INI(%s) does not exist", varname); |
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 think this message should be "INI Setting "%s" does not exist"
@yohgaki using Adding a Either way, it should be a |
I like latter. ini_set($name, $value [, $ignore_error=FALSE]), ini_get($name [, $ignore_error=FALSE]). However, I expect some people will have complaint because internal functions do not allow excessive parameters. Therefore, ini_parameter_exists() may be better choice because users can emulate behavior with script. I'll make these RFC vote option. |
Going back to @dshafik's argument, I would far prefer to see an addition of a parameter but rather than it error to throw an exception. This way I can handle it accordingly whereas having an error itself would prove to be more work by having to handle the error condition and swap error handlers.
Now in this case, I can define how I feel about the error condition and if I want to catch for instance on a non-existence I can. I really like that this will provide some error mechanism but having the ability to throw and catch (even in real-world production code) is very useful. |
Closing this due to inactivity. Please open a new PR and link to this if active work is being put back into it. |
Have you ever been frustrated by typo in ini_set() / ini_get() INI name?
This PR add ini_set() / ini_get() error reporting.
e.g. ini_set('does_not_exist', 1234); // Raise E_WARNING
To report INI errors, enable report_ini_error.
i.e. ini_set('report_ini_error', 1);
Travis spotted obsolete INI usage errors of our test codes
https://travis-ci.org/php/php-src/jobs/156940393#L1359
https://travis-ci.org/php/php-src/jobs/156940393#L1527
https://travis-ci.org/php/php-src/jobs/156940393#L1554
https://travis-ci.org/php/php-src/jobs/156940393#L1562