From df9bd6d842e093e9abb57c86ee6cdcf7aee9f9e9 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 17 Jan 2026 07:20:12 +0100 Subject: add patch for PHP 8.5 re-license spec file to CECILL-2.1 --- php-sqlsrv.spec | 46 ++++++++++++---------------------------------- php85.patch | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 php85.patch diff --git a/php-sqlsrv.spec b/php-sqlsrv.spec index 29e0813..8ca17f8 100644 --- a/php-sqlsrv.spec +++ b/php-sqlsrv.spec @@ -1,8 +1,8 @@ # remirepo spec file for php-sqlsrv # -# Copyright (c) 2016-2024 Remi Collet -# License: CC-BY-SA-4.0 -# http://creativecommons.org/licenses/by-sa/4.0/ +# SPDX-FileCopyrightText: Copyright 2016-2026 Remi Collet +# SPDX-License-Identifier: CECILL-2.1 +# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt # # Please, preserve the changelog entries # @@ -25,7 +25,7 @@ Name: %{?scl_prefix}php-sqlsrv Summary: Microsoft Drivers for PHP for SQL Server %global tarversion 5.12.0 Version: 5.12.0 -Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 2%{?dist} License: MIT URL: https://github.com/Microsoft/msphpsql @@ -36,6 +36,9 @@ Source1: http://pecl.php.net/get/pdo_%{extname}-%{tarversion}.tgz Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}-%{gh_short}.tar.gz %endif +# See https://github.com/microsoft/msphpsql/pull/1543 +Patch0: php85.patch + BuildRequires: make BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?dtsprefix}gcc-c++ @@ -44,13 +47,8 @@ BuildRequires: %{?scl_prefix}php-devel >= 8.1 BuildRequires: %{?scl_prefix}php-pdo BuildRequires: %{?scl_prefix}php-pear BuildRequires: unixODBC-devel >= 2.3.1 -%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8 BuildRequires:(msodbcsql18 >= %{msodbcsqlver18} or msodbcsql17 >= %{msodbcsqlver17}) Requires: (msodbcsql18%{?_isa} >= %{msodbcsqlver18} or msodbcsql17%{?_isa} >= %{msodbcsqlver17}) -%else -BuildRequires: msodbcsql17 >= %{msodbcsqlver17} -Requires: msodbcsql17%{?_isa} >= %{msodbcsqlver17} -%endif # ABI check Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} Requires: %{?scl_prefix}php(api) = %{php_core_api} @@ -108,7 +106,7 @@ cd NTS cd %{extname} : no patch cd ../pdo_%{extname} -: no patch +%patch -P0 -p3 cd .. # Sanity check, really often broken @@ -224,31 +222,7 @@ install -D -m 644 %{ininame} %{buildroot}%{php_ztsinidir}/%{ininame} %endif -%if 0%{?fedora} < 24 && 0%{?rhel} < 8 -# when pear installed alone, after us -%triggerin -- %{?scl_prefix}php-pear -if [ -x %{__pecl} ] ; then - %{pecl_install} %{pecl_xmldir}/php-pecl-%{extname}.xml >/dev/null || : - %{pecl_install} %{pecl_xmldir}/php-pecl-pdo-%{extname}.xml >/dev/null || : -fi - -# posttrans as pear can be installed after us -%posttrans -if [ -x %{__pecl} ] ; then - %{pecl_install} %{pecl_xmldir}/php-pecl-%{extname}.xml >/dev/null || : - %{pecl_install} %{pecl_xmldir}/php-pecl-pdo-%{extname}.xml >/dev/null || : -fi - -%postun -if [ $1 -eq 0 -a -x %{__pecl} ] ; then - %{pecl_uninstall} %{extname} >/dev/null || : - %{pecl_uninstall} pdo_%{extname} >/dev/null || : -fi -%endif - - %files -%{!?_licensedir:%global license %%doc} %license LICENSE %{pecl_xmldir}/php-pecl-%{extname}.xml %{pecl_xmldir}/php-pecl-pdo-%{extname}.xml @@ -265,6 +239,10 @@ fi %changelog +* Sat Jan 17 2026 Remi Collet - 5.12.0-2 +- add patch for PHP 8.5 +- re-license spec file to CECILL-2.1 + * Thu Feb 1 2024 Remi Collet - 5.12.0-1 - update to 5.12.0 diff --git a/php85.patch b/php85.patch new file mode 100644 index 0000000..1f58929 --- /dev/null +++ b/php85.patch @@ -0,0 +1,57 @@ +From bad3c5e0058aa519d9e389739997dd94a8e697ed Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Samuel=20=C5=A0tancl?= +Date: Sun, 19 Oct 2025 23:11:41 +0200 +Subject: [PATCH] PHP 8.5 (compilation) support + +Since https://github.com/php/php-src/pull/17741, dbh->error_mode is +stored as uint8_t. We cast the value to pdo_error_mode for the +assignment to work. + +Since https://github.com/php/php-src/pull/17742, query_stmt_zval has +been replaced by query_stmt_obj. The diff in the linked PR shows +the new destructor usage. We follow that same usage in this commit. +--- + source/pdo_sqlsrv/pdo_dbh.cpp | 4 ++-- + source/pdo_sqlsrv/php_pdo_sqlsrv_int.h | 7 ++++++- + 2 files changed, 8 insertions(+), 3 deletions(-) + +diff --git a/source/pdo_sqlsrv/pdo_dbh.cpp b/source/pdo_sqlsrv/pdo_dbh.cpp +index 8f39e72fd..075134e05 100644 +--- a/source/pdo_sqlsrv/pdo_dbh.cpp ++++ b/source/pdo_sqlsrv/pdo_dbh.cpp +@@ -625,7 +625,7 @@ int pdo_sqlsrv_db_handle_factory( _Inout_ pdo_dbh_t *dbh, _In_opt_ zval *driver_ + PDO_LOG_DBH_ENTRY; + + hash_auto_ptr pdo_conn_options_ht; +- pdo_error_mode prev_err_mode = dbh->error_mode; ++ pdo_error_mode prev_err_mode = static_cast( dbh->error_mode ); + + // must be done in all cases so that even a failed connection can query the + // object for errors. +@@ -1604,7 +1604,7 @@ zend_string * pdo_sqlsrv_dbh_last_id(_Inout_ pdo_dbh_t *dbh, _In_ const zend_str + PDO_LOG_DBH_ENTRY; + + // turn off any error handling for last_id +- pdo_error_mode prev_err_mode = dbh->error_mode; ++ pdo_error_mode prev_err_mode = static_cast( dbh->error_mode ); + dbh->error_mode = PDO_ERRMODE_SILENT; + + sqlsrv_malloc_auto_ptr driver_stmt; +diff --git a/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h b/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h +index a0a6dd89b..4ce153261 100644 +--- a/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h ++++ b/source/pdo_sqlsrv/php_pdo_sqlsrv_int.h +@@ -301,7 +301,12 @@ inline void pdo_reset_dbh_error( _Inout_ pdo_dbh_t* dbh ) + // release the last statement from the dbh so that error handling won't have a statement passed to it + if( dbh->query_stmt ) { + dbh->query_stmt = NULL; +- zval_ptr_dtor( &dbh->query_stmt_zval ); ++ #if PHP_VERSION_ID < 80500 ++ zval_ptr_dtor( &dbh->query_stmt_zval ); ++ #else ++ OBJ_RELEASE( dbh->query_stmt_obj ); ++ dbh->query_stmt_obj = NULL; ++ #endif + } + + // if the driver isn't valid, just return (PDO calls close sometimes more than once?) -- cgit