Skip to content

Promote warnings to exceptions in the standard lib #4937

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

Conversation

kocsismate
Copy link
Member

@kocsismate kocsismate commented Nov 20, 2019

I tried to choose warnings where promotion didn't seem problematic. I committed all the promotions separately, but I can also explode() the PR into smaller ones.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

I'm not exactly sure if the ones related to files/ftp should be changed to Errors so I'll hand of the decision to somebody more knowledgable.

@Girgias
Copy link
Member

Girgias commented Nov 20, 2019

Test failures are legit, mostly about fscanf which need to be updated.

@kocsismate kocsismate force-pushed the standard-exceptions branch 5 times, most recently from 5611f2b to b0de09a Compare November 22, 2019 11:21
@kocsismate kocsismate force-pushed the standard-exceptions branch 2 times, most recently from 1ad3b16 to 2e15b92 Compare November 22, 2019 13:12
@kocsismate
Copy link
Member Author

Huh, finally the tests are going to be green after my latest fix...

@@ -361,7 +361,7 @@ function is_uploaded_file(string $path): bool {}

function move_uploaded_file(string $path, string $new_path): bool {}

function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array {}
function parse_ini_file(string $filename, bool $process_sections = false, int $scanner_mode = INI_SCANNER_NORMAL): array|false {}
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this change the wrong way around?

Copy link
Member Author

@kocsismate kocsismate Dec 5, 2019

Choose a reason for hiding this comment

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

I believe it's not, because as far as I saw parse_ini_file() can also return false:

RETURN_FALSE;

@nikic
Copy link
Member

nikic commented Dec 5, 2019

A lot in here that is not very clear-cut...

Feel free to already commit the log and settype changes, and the htmlspecialchars capitalization fix.

@nikic
Copy link
Member

nikic commented Dec 5, 2019

The file_get_contents change is fine as well.

@@ -618,7 +618,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
if (numVars) {
for (i = varStart;i < argCount;i++){
if ( ! Z_ISREF(args[ i ] ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

Convert this into ZEND_ASSERT(Z_ISREF(args[i])), it should never fail.

@@ -3202,7 +3202,7 @@ static int user_shutdown_function_call(zval *zv) /* {{{ */
if (!zend_is_callable(&shutdown_function_entry->arguments[0], 0, NULL)) {
zend_string *function_name
= zend_get_callable_name(&shutdown_function_entry->arguments[0]);
php_error(E_WARNING, "(Registered shutdown functions) Unable to call %s() - function does not exist", ZSTR_VAL(function_name));
zend_value_error("(Registered shutdown functions) Unable to call %s() - function does not exist", ZSTR_VAL(function_name));
Copy link
Member

Choose a reason for hiding this comment

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

A potential problem here is that this warnings is triggered during shutdown, so there is actually no way to catch the exception. Maybe that's okay though, I'm not sure.

@kocsismate
Copy link
Member Author

Thanks Nikita for the review! I admit, these changes only seemed "clear cut" for the first sight. I believe though that warning promotions for the password_*() and chgrp() functions should be fine as well. And it might be the case for the ones too related to extension handling, ini file parsing, and to proc_open().

@nikic
Copy link
Member

nikic commented Dec 6, 2019

@kocsismate chgrp is fine modulo two nits. password_* will require corresponding changes in ext/sodium, some of the code is duplicated there.

@kocsismate
Copy link
Member Author

kocsismate commented Dec 6, 2019

@nikic OK, I'll close this PR then, and will split off these two ones + the changes for sscanf into separate PRs. The following changes were committed to the master: 5898e8e ad4d663 04deb53 d2868ed

@nikic
Copy link
Member

nikic commented Dec 10, 2019

Btw, I'm not saying the rest here can't land, I just didn't review it in detail. I can take another look after a rebase.

@kocsismate
Copy link
Member Author

kocsismate commented Dec 10, 2019

OK, sorry, I misunderstood your words a little bit. I've just rebased to current master (I hope it worked :S).

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