Skip to content

Commit 1f0661d

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Strip MariaDB 10 prefix
2 parents 6af65ea + 5fc0db9 commit 1f0661d

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ PHP NEWS
1818
- MBString:
1919
. Fixed bug GH-7902 (mb_send_mail may delimit headers with LF only). (cmb)
2020

21+
- MySQLnd:
22+
. Fixed bug GH-7972 (MariaDB version prefix 5.5.5- is not stripped). (Kamil Tekiela)
23+
2124
- pcntl:
2225
. Fixed pcntl_rfork build for DragonFlyBSD. (David Carlier)
2326

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
@@ -1279,14 +1279,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_server_version)(const MYSQLND_CONN_DATA *
12791279
return 0;
12801280
}
12811281

1282-
#define MARIA_DB_VERSION_HACK_PREFIX "5.5.5-"
1283-
1284-
if ((conn->server_capabilities & CLIENT_PLUGIN_AUTH)
1285-
&& !strncmp(p, MARIA_DB_VERSION_HACK_PREFIX, sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1))
1286-
{
1287-
p += sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1;
1288-
}
1289-
12901282
major = ZEND_STRTOL(p, &p, 10);
12911283
p += 1; /* consume the dot */
12921284
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)