Skip to content

Notice and Warning promotion in ext/zip #5823

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 8 commits into from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jul 8, 2020

IMHO Most of these notices should have been warnings already as similar error states to those were warnings in other extensions, therefore I also promoted them to ValueErrors

@remicollet
Copy link
Member

Sorry but I don't like this one, especially the php_zip_parse_options part.

In previous versions, we don't have any notice/warning

And I don't think we should be stricter than function arg parsing, so only raise exception in strict mode.

@Girgias
Copy link
Member Author

Girgias commented Jul 10, 2020

Sorry but I don't like this one, especially the php_zip_parse_options part.

In previous versions, we don't have any notice/warning

Are these notices/warnings new in PHP 8?

And I don't think we should be stricter than function arg parsing, so only raise exception in strict mode.

I'm not sure what you mean by this? PHP 8 will throw type errors even for internal functions and not return null + warning.

@remicollet
Copy link
Member

I mean that

<?php
function run(bool $b) {
	echo "$b" ? "Yes\n" : "No\n";
}
run(1);

run without any error.

zend_zval_type_name(option));
return false;
}
opts->remove_all_path = Z_LVAL_P(option);
Copy link
Member

Choose a reason for hiding this comment

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

it is where I say we have no waning in previous version.

@Girgias
Copy link
Member Author

Girgias commented Jul 10, 2020

Okay, I see now, so if I drop the changes in php_zip_parse_options() would it be more acceptable?

@remicollet
Copy link
Member

remicollet commented Jul 10, 2020

I'm mostly fine with TypeError, but only in strict mode.

I will read other change after the week-end.

@Girgias Girgias force-pushed the zip-error-promotion branch from 6132ee3 to be98aae Compare July 20, 2020 10:36
@@ -348,25 +349,62 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts)
#endif

if ((option = zend_hash_str_find(options, "remove_all_path", sizeof("remove_all_path") - 1)) != NULL) {
if (Z_TYPE_P(option) != IS_FALSE && Z_TYPE_P(option) != IS_TRUE) {
if (ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there any precedent for this? I don't remember us making strict_types distinctions for something other than parameters anywhere.

@nikic
Copy link
Member

nikic commented Aug 6, 2020

Apart from php_zip_parse_options() this looks pretty good to me. For php_zip_parse_options() I would suggest not to mess with strict_types (which I think we don't do anywhere else) and only add the warnings. The warnings can be converted to errors at a later time then.

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 good to me, but maybe @remicollet wants to take another look as well.

@@ -334,7 +335,7 @@ typedef struct {
#endif
} zip_options;

static int php_zip_parse_options(HashTable *options, zip_options *opts)
static bool php_zip_parse_options(HashTable *options, zip_options *opts)
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, but I don't see any benefit changing this, and it will make merge from lower version harded and risky.

}

idx = zip_name_locate(intern, name, 0);
// TODO Warning?
Copy link
Member

Choose a reason for hiding this comment

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

please remove all these TODO.
unrelate to this PR
And returning FALSE is the documented behavior for not found entry.

@Girgias Girgias force-pushed the zip-error-promotion branch from bb12ed7 to d187b73 Compare August 17, 2020 12:47
@Girgias Girgias force-pushed the zip-error-promotion branch from d187b73 to 3364f8b Compare August 17, 2020 12:52
@remicollet
Copy link
Member

remicollet commented Aug 17, 2020

Thanks,

Squashed and merged

72383cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants