Skip to content

Commit 262d4c2

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Strip MariaDB 10 prefix Fix news entry for 8.1.2
2 parents aff3709 + 1f0661d commit 262d4c2

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

ext/mysqli/tests/gh7932.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
GH-7972 (MariaDB version prefix not always stripped)
3+
--EXTENSIONS--
4+
mysqli
5+
--SKIPIF--
6+
<?php
7+
require_once 'skipifconnectfailure.inc';
8+
?>
9+
--FILE--
10+
<?php
11+
require_once "connect.inc";
12+
13+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
14+
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
15+
16+
// It seems we can only test the happy path...
17+
if (str_starts_with($mysqli->server_info, '5.5.5-')) {
18+
print("Expecting stripped prefix. Found: " . $mysqli->server_info . "\n");
19+
}
20+
?>
21+
--EXPECT--

ext/mysqlnd/mysqlnd_connection.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,14 +1278,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_server_version)(const MYSQLND_CONN_DATA *
12781278
return 0;
12791279
}
12801280

1281-
#define MARIA_DB_VERSION_HACK_PREFIX "5.5.5-"
1282-
1283-
if ((conn->server_capabilities & CLIENT_PLUGIN_AUTH)
1284-
&& !strncmp(p, MARIA_DB_VERSION_HACK_PREFIX, sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1))
1285-
{
1286-
p += sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1;
1287-
}
1288-
12891281
major = ZEND_STRTOL(p, &p, 10);
12901282
p += 1; /* consume the dot */
12911283
minor = ZEND_STRTOL(p, &p, 10);

ext/mysqlnd/mysqlnd_wireprotocol.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const char mysqlnd_read_body_name[] = "mysqlnd_read_body";
4141
#define ERROR_MARKER 0xFF
4242
#define EODATA_MARKER 0xFE
4343

44+
#define MARIADB_RPL_VERSION_HACK "5.5.5-"
45+
4446
/* {{{ mysqlnd_command_to_text */
4547
const char * const mysqlnd_command_to_text[COM_END] =
4648
{
@@ -369,6 +371,11 @@ php_mysqlnd_greet_read(MYSQLND_CONN_DATA * conn, void * _packet)
369371
DBG_RETURN(PASS);
370372
}
371373

374+
/* MariaDB always sends 5.5.5 before version string: 5.5.5 was never released,
375+
so just ignore it */
376+
if (!strncmp((char *) p, MARIADB_RPL_VERSION_HACK, sizeof(MARIADB_RPL_VERSION_HACK) - 1))
377+
p+= sizeof(MARIADB_RPL_VERSION_HACK) - 1;
378+
372379
packet->server_version = estrdup((char *)p);
373380
p+= strlen(packet->server_version) + 1; /* eat the '\0' */
374381
BAIL_IF_NO_MORE_DATA;

0 commit comments

Comments
 (0)