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
Remove E_STRICT notice in mysqli extension #4406
Conversation
I'm not sure on this one. I feel it might make more sense to drop the E_STRICT instead. Basically it tries to force you to write
instead of
But probably there's a reason why the former version is recommended (something about error handling?), maybe someone with MySQL familiarity can comment. @johannes? |
I believe that is consequence of the original developer staying close to C patterns instead of going for PHP patterns. I am not sure what state the result is in after |
So I'm a bit confused about this code tbh, I've had a look around it trying to understand it but it seems this section calls the It is true that the E_STRICT notice should probably be dropped. I'm going to commit/push that change and see if it breaks anything on CI. |
@Girgias, ext/mysqli works either with the mysqlnd driver, or with libmysqlclient. |
mysqlnd is the "library" providing a C API for other PHP extensions for handling MySQL protocol.
See https://www.php.net/manual/en/mysql.php which has some more details. Feel free to ping my outside this discussion for question (same username as here @ php.net, just to stay in topic within this item) |
If you drop it, would be good to check what happens if you call result APIs after Something like
I am not sure what to expect, I think all those later operations should fail gracefully ... They shouldn't return the first result set. On the other hand if they for whatever reason return the first result set it might be good to enforce the (Untested and typed on mobile ...) |
Thanks for the explanations :) Will add a test to see if it fails gracefully or not and will report back. |
Okay added a test, this should work. I couldn't use |
@johannes is the added test sufficient or should I do something more specialised? |
For reference, this is the usage example from the MySQL docs: https://dev.mysql.com/doc/refman/8.0/en/c-api-multiple-queries.html They use a do/while loop on |
Looking at the results on your added tests, it seems like @johannes conjecture was right and the first result set is returned, instead of subsequent result set operations failing. |
Now the question is: Is that ok? The easy answer is "yes, if you ignore the return code it's your fault" as long as it doesn't crash we are fine. Another answer might be "no, all subsequent result operations should fail" I'm not sure. |
I mean it was always possible to do that if you ignored the E_STRICT warning so I would say leaving it as if would be the better option. I don't know if this should be changed in PHP 8? So should I replace that by a deprecated notice? |
The difference is: The "old" suggestion is "check using The question is what the livelihood of errors is. i.e. if users issue a |
It seems to me that Anyhow, would the code work the same with libmysqlclient? |
@cmb69 Uh yeah sorry, my code doesn't make sense. I think in the end the two relevant use cases here are a) you are reading results in a loop, in which case just using next_result() would be preferable and the warning should go away or b) you are reading a specific (known) number of result sets without checking the next_result return value, in which case the warning might help you realize your mistake. |
Consider the following: $conn->multi_query("SELECT 1;SELECT * FROM missing_table");
var_dump($conn->next_result());
var_dump($res = $conn->store_result());
var_dump($res->fetch_array()); This fetches the result of the first query without any warning/notice. I don't think the internal more_results() check triggering a warning/notice is actually that helpful, since users need to check the return value of
yes |
bf92341
to
3067187
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consensus seems to be on dropping the E_STRICT notice, so let's do it.
Merged in as e895e96 |
Split mysqli error conversion from #4401