Skip to content
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

Mysqli warning promotion #5803

Closed
wants to merge 12 commits into from
Closed

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jul 3, 2020

I will split this extension into multiple PRs as it's already starting to become rather large.

ext/mysqli/mysqli_api.c Outdated Show resolved Hide resolved
ext/mysqli/mysqli_api.c Outdated Show resolved Hide resolved
@Girgias Girgias force-pushed the mysqli-warning-promotion branch 9 times, most recently from d1d1ac2 to 6131745 Compare July 9, 2020 18:04
@Girgias Girgias force-pushed the mysqli-warning-promotion branch 2 times, most recently from f5e67f1 to 777f11c Compare July 20, 2020 12:49
@Girgias Girgias changed the title Mysqli warning promotion part 1 Mysqli warning promotion Jul 20, 2020
@Girgias Girgias force-pushed the mysqli-warning-promotion branch 3 times, most recently from d86e165 to 67e6b6a Compare August 23, 2020 22:10
@Girgias Girgias force-pushed the mysqli-warning-promotion branch 4 times, most recently from 4d53fdc to 1e66beb Compare September 9, 2020 22:36
@Girgias Girgias force-pushed the mysqli-warning-promotion branch 3 times, most recently from 26cdc04 to 15f2f4b Compare September 13, 2020 01:15
ext/mysqli/mysqli.c Outdated Show resolved Hide resolved
}

if (types_len != (size_t) argc) {
/* number of bind variables doesn't match number of elements in type definition string */
php_error_docref(NULL, E_WARNING, "Number of elements in type definition string doesn't match number of bind variables");
RETURN_FALSE;
zend_argument_count_error("Number of elements in type definition string doesn't match number of bind variables");
Copy link
Member

Choose a reason for hiding this comment

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

I think a few the is missing from this message. :) I would say The number of elements in the type definition string doesn't match the number of bind variables, but maybe it's too much now (?). Otherwise, you could say argument #2 (...) instead of type definition string.

Copy link
Member

Choose a reason for hiding this comment

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

Besides, you could use the ... must match the number of bind variables format, which is the most common wording we use (rather than ... doesn't match ...).

MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);

if (mysqli_result_is_unbuffered(result)) {
// TODO Promoto to Exception?
Copy link
Member

Choose a reason for hiding this comment

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

Yes, I do think it makes sense to forbid this case. The other PR handles this though.

ext/mysqli/mysqli_api.c Show resolved Hide resolved
ext/mysqli/mysqli_api.c Outdated Show resolved Hide resolved
@Girgias Girgias force-pushed the mysqli-warning-promotion branch 2 times, most recently from 4b52075 to 717d1fd Compare September 14, 2020 00:58
ext/mysqli/mysqli.c Outdated Show resolved Hide resolved
ext/mysqli/mysqli_api.c Outdated Show resolved Hide resolved
ext/mysqli/mysqli_api.c Outdated Show resolved Hide resolved
ext/mysqli/mysqli_api.c Outdated Show resolved Hide resolved
ext/mysqli/mysqli_api.c Show resolved Hide resolved
ext/mysqli/mysqli_nonapi.c Outdated Show resolved Hide resolved
ext/mysqli/mysqli_nonapi.c Outdated Show resolved Hide resolved
ext/mysqli/mysqli_nonapi.c Outdated Show resolved Hide resolved
ext/mysqli/tests/bug74595.phpt Outdated Show resolved Hide resolved
ext/mysqli/mysqli_nonapi.c Outdated Show resolved Hide resolved
ext/mysqli/mysqli_nonapi.c Outdated Show resolved Hide resolved
ext/mysqli/mysqli.stub.php Show resolved Hide resolved
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);

if (mysqli_result_is_unbuffered(result)) {
php_error_docref(NULL, E_WARNING, "Function cannot be used with MYSQL_USE_RESULT");
RETURN_FALSE;
zend_throw_error(NULL, "Function cannot be used with MYSQL_USE_RESULT");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
zend_throw_error(NULL, "Function cannot be used with MYSQL_USE_RESULT");
zend_throw_error(NULL, "mysqli_data_seek() cannot be used with MYSQL_USE_RESULT");

etc.

Copy link
Member

Choose a reason for hiding this comment

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

I have suggested a PR for this error. I believe the constant should be MYSQLI_USE_RESULT

Copy link
Member

Choose a reason for hiding this comment

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

Right, this should be MYSQLI_USE_RESULT.

Copy link
Member

Choose a reason for hiding this comment

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

I still think the message I suggested is better "cannot be used in MYSQLI_USE_RESULT mode". The constant describes result mode. You don't use the function with this constant but rather your result is in one or the other mode.

Copy link
Member Author

Choose a reason for hiding this comment

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

You can address this in your PR, I just want to get done with this one at this point ^^"

@nikic
Copy link
Member

nikic commented Sep 15, 2020

ext/opcache/tests/func_info.phpt is failing due to outdated zend_func_info.c.

@@ -488,7 +488,7 @@ static const func_info_t func_infos[] = {
F1("mysqli_prepare", MAY_BE_FALSE | MAY_BE_OBJECT),
F1("mysqli_real_escape_string", MAY_BE_STRING),
F1("mysqli_stmt_affected_rows", MAY_BE_LONG | MAY_BE_STRING),
F0("mysqli_stmt_data_seek", MAY_BE_NULL | MAY_BE_FALSE),
F0("mysqli_stmt_data_seek", MAY_BE_NULL),
Copy link
Member

Choose a reason for hiding this comment

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

You can just drop the line completely now.

@php-pulls php-pulls closed this in 7a95e94 Sep 15, 2020
@Girgias Girgias deleted the mysqli-warning-promotion branch September 15, 2020 17:14
@Girgias Girgias mentioned this pull request Sep 15, 2020
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.

None yet

5 participants