Merge branch 'PHP-8.1'

* PHP-8.1:
  Strip MariaDB 10 prefix
  Fix news entry for 8.1.2
This commit is contained in:
Kamil Tekiela 2022-01-19 21:45:36 +00:00
commit 262d4c220b
No known key found for this signature in database
GPG Key ID: 0760BDAB1E89A1E3
3 changed files with 28 additions and 8 deletions

View File

@ -0,0 +1,21 @@
--TEST--
GH-7972 (MariaDB version prefix not always stripped)
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once "connect.inc";
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
// It seems we can only test the happy path...
if (str_starts_with($mysqli->server_info, '5.5.5-')) {
print("Expecting stripped prefix. Found: " . $mysqli->server_info . "\n");
}
?>
--EXPECT--

View File

@ -1278,14 +1278,6 @@ MYSQLND_METHOD(mysqlnd_conn_data, get_server_version)(const MYSQLND_CONN_DATA *
return 0;
}
#define MARIA_DB_VERSION_HACK_PREFIX "5.5.5-"
if ((conn->server_capabilities & CLIENT_PLUGIN_AUTH)
&& !strncmp(p, MARIA_DB_VERSION_HACK_PREFIX, sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1))
{
p += sizeof(MARIA_DB_VERSION_HACK_PREFIX)-1;
}
major = ZEND_STRTOL(p, &p, 10);
p += 1; /* consume the dot */
minor = ZEND_STRTOL(p, &p, 10);

View File

@ -41,6 +41,8 @@ const char mysqlnd_read_body_name[] = "mysqlnd_read_body";
#define ERROR_MARKER 0xFF
#define EODATA_MARKER 0xFE
#define MARIADB_RPL_VERSION_HACK "5.5.5-"
/* {{{ mysqlnd_command_to_text */
const char * const mysqlnd_command_to_text[COM_END] =
{
@ -369,6 +371,11 @@ php_mysqlnd_greet_read(MYSQLND_CONN_DATA * conn, void * _packet)
DBG_RETURN(PASS);
}
/* MariaDB always sends 5.5.5 before version string: 5.5.5 was never released,
so just ignore it */
if (!strncmp((char *) p, MARIADB_RPL_VERSION_HACK, sizeof(MARIADB_RPL_VERSION_HACK) - 1))
p+= sizeof(MARIADB_RPL_VERSION_HACK) - 1;
packet->server_version = estrdup((char *)p);
p+= strlen(packet->server_version) + 1; /* eat the '\0' */
BAIL_IF_NO_MORE_DATA;