-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Promote some warnings to ValueError in OCI8 #6116
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
Hi @Girgias
|
@cjbj Only those warnings can be converted which are programmatic errors according to the https://wiki.php.net/rfc/engine_warnings RFC. |
Will do ASAP
As @kocsismate already said this change is more about promoting programming error Warnings to Errors instead of a blanket update, however as the maintainer of the extension I think you can promote other runtime warnings to error but that would be a separate discussion.
Seems like the best way, updating tests is usually the most cumbersome part of this process, otherwise you could always send a PR against this branch on my fork to streamline it into one commit, but either way is fine with me. :) |
19a7e26
to
793e5a5
Compare
Should all the Also what is your advice for a couple of warnings in https://github.com/php/php-src/blob/master/ext/oci8/oci8.c#L917 and later the warning (A side comment: RFCs would be better historical records if they documented in writing the outcome(s) of the vote(s), instead of leaving the 1/2 or 2/3 majority calculation to the reader. Funny how I hadn't thought of this step before; it could have been added to https://blogs.oracle.com/opal/the-mysterious-php-rfc-process-and-how-you-can-change-the-web !) |
I would promote all of them other than the charset one as I imagine there is no way to pre-check its value. The general guideline is that flag type arguments, constant minimal/maximal values and non empty string/arrays are promotable to ValueError as they do not depend on a runtime condition (I/O, user input, etc.) or are condition which are easy to check if they can improve the return type. Hope this clarifies it, but feel free to ask more questions.
That's an interesting thought :) |
@cjbj Very nice blog post! It's actually gap filling, and most of the newcomers should read it (especially the 3rd and the 4th list items... :D ). And I pretty much agree with the percentage calculation. In case you don't know about it, you can use https://php-rfc-watch.beberlei.de/ for doing so (+ getting real time updates without page refreshes ^^) |
I forgot to talk about the |
Excellent - thanks. I wish point 18 was followed - life would be easier if all emails contained the relevant RFC URL. @Girgias : |
ext/oci8/oci8_interface.c
Outdated
@@ -640,15 +635,15 @@ PHP_FUNCTION(oci_lob_erase) | |||
if (offset_is_null) { | |||
offset = -1; | |||
} else if (offset < 0) { | |||
php_error_docref(NULL, E_WARNING, "Offset must be greater than or equal to 0"); | |||
RETURN_FALSE; | |||
zend_argument_value_error(2, "must be greater than or equal to 0"); |
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.
The '2' is off-by-one for $lob->erase()
but is valid for the oci_lob_erase()
. For $lob->erase(-10)
the resulting message from the PR refers to $length
where it should be $offset
, which is the first arg.
Since oci_lob_erase()
is not documented, the simple solution is to subtract one from the parameter number and ignore the wrong message if anyone is actually using oci_lob_erase()
incorrectly . Or is there a way to distinguish between the method and function usage?
The same problem occurs for the next zend_argument_value_error()
call, and others in this file.
Tweaks and test updates for PR 6116
So no test updates currently.
@cjbj could you maybe handle that and confirm this change is okay, this attempts to align part of it with the rest of PHP extensions in PHP 8.0.