[php-src] Issue #11950: mysqlnd: error message is inappropriate in some cases
| From: | SakiTakamachi | Date: | Sat, 12 Aug 2023 16:25:32 +0000 |
| Subject: | [php-src] Issue #11950: mysqlnd: error message is inappropriate in some cases | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245163@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11950
Author: SakiTakamachi
### Description
This is an issue I noticed while working on this fix.
https://github.com/php/php-src/pull/11912
This line sets the
CR_MALFORMED_PACKET error.
https://github.com/php/php-src/blob/f907a009f9d4c6a72ad756f57b9c3ebf0eeb8666/ext/mysqlnd/mysqlnd_wireprotocol.c#L2471
However, the CR_SERVER_GONE_ERROR error may already be set at this point.
https://github.com/php/php-src/blob/f907a009f9d4c6a72ad756f57b9c3ebf0eeb8666/ext/mysqlnd/mysqlnd_wireprotocol.c#L297
Therefore, a CR_SERVER_GONE_ERROR error is output when an
CR_MALFORMED_PACKET error should be output.
```
Fatal error: Uncaught mysqli_sql_exception: Malformed packet in /var/www/html/test/test.php:11
```
I get the following error message in the same situation when building with libmysqlclient :
```
Fatal error: Uncaught mysqli_sql_exception: Lost connection to MySQL server during query in
/var/www/html/test/test.php:11
```
The code to reproduce:
```php
<?php
$driver = new mysqli_driver();
$driver->report_mode = MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT;
$mysqli = new mysqli("mysql", "root", "", "test"); // my env
fgets(STDIN);
// Restarted mysql, then press enter
var_dump($mysqli->select_db("test2"));
```
### PHP Version
PHP 8.0+
### Operating System
_No response_