From 683fd69aff896998d0c0970bdb21f1d06071d5d8 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 28 Jun 2018 09:03:01 +0200 Subject: add patch for PHP 7.3 from https://github.com/jbboehr/php-mustache/pull/48 --- 48.patch | 119 +++++++++++++++++++++++++++++++++++++++++++++++++ PHPINFO | 11 +++++ REFLECTION | 2 +- php-pecl-mustache.spec | 13 ++++-- 4 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 48.patch create mode 100644 PHPINFO diff --git a/48.patch b/48.patch new file mode 100644 index 0000000..5b8edf1 --- /dev/null +++ b/48.patch @@ -0,0 +1,119 @@ +From a6b22a380212ff2db890587669088d241d4e65bc Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 28 Jun 2018 08:46:45 +0200 +Subject: [PATCH] fix for PHP 7.3 and Array/Object recursion protection + +--- + .gitignore | 1 + + mustache_data.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 44 insertions(+) + +diff --git a/mustache_data.cpp b/mustache_data.cpp +index a73168c..c129eaa 100644 +--- a/mustache_data.cpp ++++ b/mustache_data.cpp +@@ -267,10 +267,19 @@ static zend_always_inline void mustache_data_from_array_zval(mustache::Data * no + + data_hash = HASH_OF(current); + ++#if PHP_VERSION_ID < 70300 + if( ZEND_HASH_APPLY_PROTECTION(data_hash) && ++data_hash->u.v.nApplyCount > 1 ) { + php_error(E_WARNING, "Data includes circular reference"); + data_hash->u.v.nApplyCount--; + return; ++#else ++ if (!(GC_FLAGS(data_hash) & GC_IMMUTABLE)) { ++ if (GC_IS_RECURSIVE(data_hash)) { ++ php_error(E_WARNING, "Data includes circular reference"); ++ return; ++ } ++ GC_PROTECT_RECURSION(data_hash); ++#endif + } + + data_count = zend_hash_num_elements(data_hash); +@@ -309,8 +318,13 @@ static zend_always_inline void mustache_data_from_array_zval(mustache::Data * no + } + } ZEND_HASH_FOREACH_END(); + ++#if PHP_VERSION_ID < 70300 + if( ZEND_HASH_APPLY_PROTECTION(data_hash) ) { + data_hash->u.v.nApplyCount--; ++#else ++ if (!(GC_FLAGS(data_hash) & GC_IMMUTABLE)) { ++ GC_UNPROTECT_RECURSION(data_hash); ++#endif + } + } + #endif +@@ -417,12 +431,22 @@ static zend_always_inline void mustache_data_from_object_properties_zval(mustach + data_hash = Z_OBJ_HT_P(current)->get_properties(current TSRMLS_CC); + } + if( data_hash != NULL && zend_hash_num_elements(data_hash) > 0 ) { ++#if PHP_VERSION_ID < 70300 + if( ZEND_HASH_APPLY_PROTECTION(data_hash) && ++data_hash->u.v.nApplyCount > 1 ) { + php_error(E_WARNING, "Data includes circular reference"); + data_hash->u.v.nApplyCount--; + return; ++#else ++ if (!(GC_FLAGS(data_hash) & GC_IMMUTABLE)) { ++ if (GC_IS_RECURSIVE(data_hash)) { ++ php_error(E_WARNING, "Data includes circular reference"); ++ return; ++ } ++ GC_PROTECT_RECURSION(data_hash); ++#endif + } + ++ + ZEND_HASH_FOREACH_KEY_VAL_IND(data_hash, key_nindex, key, data_entry) { + (void)key_nindex; /* avoid [-Wunused-but-set-variable] */ + if( key && ZSTR_LEN(key) && ZSTR_VAL(key)[0] ) { // skip private/protected +@@ -451,8 +475,13 @@ static zend_always_inline void mustache_data_from_object_properties_zval(mustach + } + } ZEND_HASH_FOREACH_END(); + ++#if PHP_VERSION_ID < 70300 + if( ZEND_HASH_APPLY_PROTECTION(data_hash) ) { + data_hash->u.v.nApplyCount--; ++#else ++ if (!(GC_FLAGS(data_hash) & GC_IMMUTABLE)) { ++ GC_UNPROTECT_RECURSION(data_hash); ++#endif + } + } + } +@@ -519,10 +548,19 @@ static zend_always_inline void mustache_data_from_object_functions_zval(mustache + data_hash = &ce->function_table; + } + if( data_hash != NULL && zend_hash_num_elements(data_hash) > 0 ) { ++#if PHP_VERSION_ID < 70300 + if( ZEND_HASH_APPLY_PROTECTION(data_hash) && ++data_hash->u.v.nApplyCount > 1 ) { + php_error(E_WARNING, "Data includes circular reference"); + data_hash->u.v.nApplyCount--; + return; ++#else ++ if (!(GC_FLAGS(data_hash) & GC_IMMUTABLE)) { ++ if (GC_IS_RECURSIVE(data_hash)) { ++ php_error(E_WARNING, "Data includes circular reference"); ++ return; ++ } ++ GC_PROTECT_RECURSION(data_hash); ++#endif + } + + ZEND_HASH_FOREACH_KEY_VAL_IND(data_hash, key_nindex, key, data_entry) { +@@ -542,8 +580,13 @@ static zend_always_inline void mustache_data_from_object_functions_zval(mustache + } + } ZEND_HASH_FOREACH_END(); + ++#if PHP_VERSION_ID < 70300 + if( ZEND_HASH_APPLY_PROTECTION(data_hash) ) { + data_hash->u.v.nApplyCount--; ++#else ++ if (!(GC_FLAGS(data_hash) & GC_IMMUTABLE)) { ++ GC_UNPROTECT_RECURSION(data_hash); ++#endif + } + } + } diff --git a/PHPINFO b/PHPINFO new file mode 100644 index 0000000..77baf13 --- /dev/null +++ b/PHPINFO @@ -0,0 +1,11 @@ + +mustache + +Version => 0.7.4 +Released => 2017-07-18 +Revision => master +Authors => John Boehr (lead) +Spec Version => 1.1.2 +Libmustache Version => 0.4.4 +Libmustache Operand Size => 2 +c++11 unordered map support => enabled diff --git a/REFLECTION b/REFLECTION index e9f0374..cae9955 100644 --- a/REFLECTION +++ b/REFLECTION @@ -1,4 +1,4 @@ -Extension [ extension #111 mustache version 0.7.4 ] { +Extension [ extension #116 mustache version 0.7.4 ] { - Classes [8] { Class [ class MustacheAST ] { diff --git a/php-pecl-mustache.spec b/php-pecl-mustache.spec index ffaff3c..b614330 100644 --- a/php-pecl-mustache.spec +++ b/php-pecl-mustache.spec @@ -1,6 +1,6 @@ # remirepo spec file for php-pecl-mustache # -# Copyright (c) 2017 Remi Collet +# Copyright (c) 2017-2018 Remi Collet # License: CC-BY-SA # http://creativecommons.org/licenses/by-sa/4.0/ # @@ -26,12 +26,14 @@ Summary: Mustache templating language Name: %{?sub_prefix}php-pecl-%{pecl_name} Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}} -Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: MIT Group: Development/Languages URL: http://pecl.php.net/package/%{pecl_name} Source0: http://pecl.php.net/get/%{pecl_name}-%{upstream_version}%{?upstream_prever}.tgz +Patch0: https://patch-diff.githubusercontent.com/raw/jbboehr/php-mustache/pull/48.patch + BuildRequires: %{?scl_prefix}php-devel >= 5.4 BuildRequires: %{?scl_prefix}php-pear BuildRequires: pkgconfig(mustache) @@ -96,6 +98,7 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd NTS +%patch0 -p1 -b .pr48 # Sanity check, really often broken extver=$(sed -n '/PHP_MUSTACHE_VERSION/{s/.* "//;s/".*$//;p}' php_mustache.h) @@ -169,7 +172,7 @@ do install -Dpm 644 NTS/$i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i done -%if 0%{?fedora} < 24 +%if 0%{?fedora} < 24 && 0%{?rhel} < 8 # when pear installed alone, after us %triggerin -- %{?scl_prefix}php-pear if [ -x %{__pecl} ] ; then @@ -240,6 +243,10 @@ REPORT_EXIT_STATUS=1 \ %changelog +* Thu Jun 28 2018 Remi Collet - 0.7.4-2 +- add patch for PHP 7.3 from + https://github.com/jbboehr/php-mustache/pull/48 + * Wed Jul 19 2017 Remi Collet - 0.7.4-1 - update to 0.7.4 (stable) -- cgit