Uh oh!
There was an error while loading. Please reload this page.
Remove E_STRICT notice in mysqli extension - #4406
Conversation
nikic
commented
Jul 15, 2019
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? |
johannes
commented
Jul 15, 2019
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 |
Girgias
commented
Jul 15, 2019
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. |
cmb69
commented
Jul 15, 2019
@Girgias, ext/mysqli works either with the mysqlnd driver, or with libmysqlclient. |
johannes
commented
Jul 15, 2019
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) |
johannes
commented
Jul 15, 2019
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 ...) |
Girgias
commented
Jul 15, 2019
Thanks for the explanations :) Will add a test to see if it fails gracefully or not and will report back. |
Girgias
commented
Jul 15, 2019
Okay added a test, this should work. I couldn't use |
Girgias
commented
Jul 16, 2019
@johannes is the added test sufficient or should I do something more specialised? |
nikic
commented
Jul 18, 2019
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 |
Uh oh!
There was an error while loading. Please reload this page.
nikic
commented
Jul 18, 2019
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. |
johannes
commented
Jul 18, 2019
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. |
Girgias
commented
Jul 18, 2019
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? |
johannes
commented
Jul 18, 2019
The difference is: The "old" suggestion is "check using The question is what the livelihood of errors is. i.e. if users issue a |
cmb69
commented
Jul 18, 2019
It seems to me that Anyhow, would the code work the same with libmysqlclient? |
nikic
commented
Jul 18, 2019
@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. |
cmb69
commented
Jul 19, 2019
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
3067187CompareGirgias
commented
Aug 6, 2019
nikic
left a comment
There was a problem hiding this comment.
Consensus seems to be on dropping the E_STRICT notice, so let's do it.
Girgias
commented
Aug 31, 2019
Merged in as e895e96 |
Split mysqli error conversion from #4401