Skip to content

Fix UNKNOWN default values in ext/oci8 #6089

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

Closed
wants to merge 3 commits into from

Conversation

kocsismate
Copy link
Member

No description provided.

@kocsismate
Copy link
Member Author

kocsismate commented Sep 7, 2020

@cjbj Can you help us get this PR tested since we have no (easy) way to test these changes?

@cjbj
Copy link
Contributor

cjbj commented Sep 8, 2020

@kocsismate I'm happy to help, and appreciate the PR. Can you describe the problem you are solving - I haven't dug into stubs a lot.

Copy link
Contributor

@cjbj cjbj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the syntax corrected, tests results are the same as previously.

if (!getThis() && ZEND_NUM_ARGS() > 2 && length < 0) {
if (length_is_null) {
length = -1;
else if (length < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a closing brace for the first clause:

--- a/ext/oci8/oci8_interface.c
+++ b/ext/oci8/oci8_interface.c
@@ -641,7 +641,7 @@ PHP_FUNCTION(oci_lob_erase)
 
 	if (length_is_null) {
 		length = -1;
-	else if (length < 0) {
+	} else if (length < 0) {
 		php_error_docref(NULL, E_WARNING, "Length must be greater than or equal to 0");
 		RETURN_FALSE;
 	}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhh :/

@kocsismate
Copy link
Member Author

@cjbj Thank you very much for the help!

Can you describe the problem you are solving - I haven't dug into stubs a lot.

The reason of these changes is that the functions which are marked with an UNKNOWN default value in stubs don't handle those default values properly. Ideally the function's behavior should be the same when an optional parameter is supplied with its default value and when this parameter is not supplied. Internal functions used to have hundreds of glitches like this, but now we're down to just a few dozens of them. :)

@cjbj
Copy link
Contributor

cjbj commented Sep 8, 2020

Thanks for the info and PR. LGTM.

@@ -757,9 +749,10 @@ PHP_FUNCTION(oci_lob_copy)
{
zval *tmp_dest, *tmp_from, *z_descriptor_dest, *z_descriptor_from;
php_oci_descriptor *descriptor_dest, *descriptor_from;
zend_long length = 0;
zend_long length = -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have the same issue with the default value here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I didn't notice it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the same problem in oci_lob_export() as well.

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks right to me now.

@php-pulls php-pulls closed this in 3b0fecd Sep 8, 2020
@kocsismate kocsismate deleted the unknown-default-oci8 branch September 8, 2020 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants