Skip to content

Promote warnings to exceptions in the standard lib - #4937

Closed
kocsismate wants to merge 21 commits into
php:masterfrom
kocsismate:standard-exceptions
Closed

Promote warnings to exceptions in the standard lib#4937
kocsismate wants to merge 21 commits into
php:masterfrom
kocsismate:standard-exceptions

Conversation

@kocsismate

@kocsismatekocsismate commented Nov 20, 2019

Copy link
Copy Markdown
Member

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.

Comment threadext/standard/password.c Outdated

@GirgiasGirgias left a comment

Copy link
Copy Markdown
Member

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.

Comment threadext/standard/string.c Outdated
Comment threadext/standard/tests/general_functions/bug72920.phpt Outdated
Comment threadext/standard/tests/general_functions/gettype_settype_error.phpt Outdated
Comment threadext/standard/tests/general_functions/proc_open_pipes3.phpt Outdated
@Girgias

Copy link
Copy Markdown
Member

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

@kocsismate
kocsismateforce-pushed the standard-exceptions branch 5 times, most recently from 5611f2b to b0de09aCompareNovember 22, 2019 11:21
@kocsismate
kocsismateforce-pushed the standard-exceptions branch 2 times, most recently from 1ad3b16 to 2e15b92CompareNovember 22, 2019 13:12
@kocsismate

Copy link
Copy Markdown
MemberAuthor

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

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
Copy Markdown
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?

@kocsismatekocsismateDec 5, 2019

Copy link
Copy Markdown
MemberAuthor

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:

@nikic

nikic commented Dec 5, 2019

Copy link
Copy Markdown
Member

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

nikic commented Dec 5, 2019

Copy link
Copy Markdown
Member

The file_get_contents change is fine as well.

Comment threadext/standard/scanf.c
@@ -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
Copy Markdown
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.

Comment threadext/standard/scanf.c
Comment threadext/standard/uuencode.c
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
Copy Markdown
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
Copy Markdown
MemberAuthor

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().

Comment threadext/standard/filestat.c
Comment threadext/standard/filestat.c
@nikic

nikic commented Dec 6, 2019

Copy link
Copy Markdown
Member

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

@kocsismate

kocsismate commented Dec 6, 2019

Copy link
Copy Markdown
MemberAuthor

@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: 5898e8ead4d66304deb53d2868ed

@nikic

Copy link
Copy Markdown
Member

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

kocsismate commented Dec 10, 2019

Copy link
Copy Markdown
MemberAuthor

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

Sign up for freeto 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

@kocsismate@Girgias@nikic@cmb69