[packages/php-pecl-mysql] Rel 12. Fix build with PHP 8.6

arekm arekm at pld-linux.org
Sat Nov 21 23:06:38 CET 2026


commit 1fcbc84db07924ad4f50bee523e9bd4e16ea3449
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Nov 21 23:05:36 2026 +0100

    Rel 12. Fix build with PHP 8.6

 fetch-object-ctor-args-leak.patch | 16 +++++++++++++
 php-pecl-mysql.spec               |  7 ++++--
 php86.patch                       | 47 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+), 2 deletions(-)
---
diff --git a/php-pecl-mysql.spec b/php-pecl-mysql.spec
index 69d41d2..73d639e 100644
--- a/php-pecl-mysql.spec
+++ b/php-pecl-mysql.spec
@@ -3,7 +3,7 @@
 %bcond_without	tests		# build without tests
 %bcond_without	mysqlnd		# without mysqlnd support in mysql related extensions
 
-%define		rel		11
+%define		rel		12
 %define		commit	ca514c4
 %define		php_name	php%{?php_suffix}
 %define		modname	mysql
@@ -20,8 +20,9 @@ Source0:	https://github.com/php/pecl-database-mysql/archive/%{commit}/php-pecl-%
 # Source0-md5:	352114d54e0889d999577f9db8c06a74
 Patch0:		revert-deprecate-ext-mysql.patch
 Patch1:		build.patch
+Patch2:		php86.patch
+Patch3:		fetch-object-ctor-args-leak.patch
 URL:		https://secure.php.net/manual/en/book.mysql.php
-%{?with_tests:BuildRequires:    %{php_name}-cli}
 BuildRequires:	%{php_name}-devel >= 4:7.0.0
 %{?with_mysqlnd:BuildRequires:	%{php_name}-mysqlnd}
 BuildRequires:	rpmbuild(macros) >= 1.666
@@ -51,6 +52,8 @@ historical reasons only.
 mv pecl-database-%{modname}-*/* .
 %patch -P0 -p1
 %patch -P1 -p1
+%patch -P2 -p1
+%patch -P3 -p1
 
 cat <<'EOF' > run-tests.sh
 #!/bin/sh
diff --git a/fetch-object-ctor-args-leak.patch b/fetch-object-ctor-args-leak.patch
new file mode 100644
index 0000000..8a819a1
--- /dev/null
+++ b/fetch-object-ctor-args-leak.patch
@@ -0,0 +1,16 @@
+mysql_fetch_object() freed only the array of constructor arguments, leaking
+the reference zend_fcall_info_args() took on each of them.
+
+--- a/php_mysql.c	2026-11-21 23:03:45.616666666 +0100
++++ b/php_mysql.c	2026-11-21 23:03:45.703333333 +0100
+@@ -2338,9 +2338,7 @@ static void php_mysql_fetch_hash(INTERNA
+ 					zval_ptr_dtor(&retval);
+ 				}
+ 			}
+-			if (fci.params) {
+-				efree(fci.params);
+-			}
++			zend_fcall_info_args_clear(&fci, 1);
+ 		} else if (ctor_params) {
+ 			zend_throw_exception_ex(zend_ce_exception, 0, "Class %s does not have a constructor hence you cannot use ctor_params", ZSTR_VAL(ce->name));
+ 		}
diff --git a/php86.patch b/php86.patch
new file mode 100644
index 0000000..444cd38
--- /dev/null
+++ b/php86.patch
@@ -0,0 +1,47 @@
+PHP 8.6 dropped zval_dtor(), added zend_fcall_info.consumed_args (left
+uninitialized here, so constructor arguments could be moved out instead of
+copied) and made php_get_current_user() return zend_string *; the latter is
+used only in the sql_safe_mode branch, which is dead since PHP 7.2, so
+compile it only where the setting exists.
+
+--- a/php_mysql.c	2026-11-21 22:59:32.936666666 +0100
++++ b/php_mysql.c	2026-11-21 23:03:45.606666666 +0100
+@@ -777,9 +777,6 @@ static void php_mysql_do_connect(INTERNA
+ 
+ #if PHP_API_VERSION < 20160731
+ 	if (PG(sql_safe_mode)) {
+-#else
+-	if (0) {
+-#endif
+ 		if (ZEND_NUM_ARGS()>0) {
+ 			php_error_docref(NULL, E_NOTICE, "SQL safe mode in effect - ignoring host/user/password information");
+ 		}
+@@ -787,7 +784,9 @@ static void php_mysql_do_connect(INTERNA
+ 		hashed_details = zend_string_alloc(sizeof("mysql___") + strlen(user) - 1, 0);
+ 		snprintf(ZSTR_VAL(hashed_details), ZSTR_LEN(hashed_details) + 1, "mysql__%s_", user);
+ 		client_flags = CLIENT_INTERACTIVE;
+-	} else {
++	} else
++#endif
++	{
+ 		/* mysql_pconnect does not support new_link parameter */
+ 		if (persistent) {
+ 			if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!l", &host_and_port, &host_len,
+@@ -2275,7 +2274,7 @@ static void php_mysql_fetch_hash(INTERNA
+ 	/* mysqlnd might return FALSE if no more rows */
+ 	if (into_object && Z_TYPE_P(return_value) != IS_FALSE) {
+ 		zval dataset;
+-		zend_fcall_info fci;
++		zend_fcall_info fci = {0};
+ 		zend_fcall_info_cache fcc;
+ 		zval retval;
+ 
+@@ -2285,7 +2284,7 @@ static void php_mysql_fetch_hash(INTERNA
+ 			Z_OBJ_P(return_value)->properties = Z_ARR(dataset);
+ 		} else {
+ 			zend_merge_properties(return_value, Z_ARRVAL(dataset));
+-			zval_dtor(&dataset);
++			zval_ptr_dtor_nogc(&dataset);
+ 		}
+ 
+ 		if (ce->constructor) {
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/php-pecl-mysql.git/commitdiff/1fcbc84db07924ad4f50bee523e9bd4e16ea3449



More information about the pld-cvs-commit mailing list