From 89951b237e12c64815fb1490a04aded359c202e2 Mon Sep 17 00:00:00 2001 From: mdabrowski Date: Tue, 27 Oct 2026 07:52:18 +0100 Subject: [PATCH 1/7] Create composer file to make it compatible with PIE --- composer.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 composer.json diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..74ad556 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "wikia/php-mustache", + "type": "php-ext", + "description": "Mustache templating language extension for PHP (Fandom fork)", + "license": "MIT", + "require": { + "php": ">=8.1" + }, + "php-ext": { + "extension-name": "mustache", + "configure-options": [ + { + "name": "with-libmustache", + "description": "libmustache installation prefix (uses pkg-config by default)", + "needs-value": true + } + ] + } +} From 435269d362fd1e09173b50ec1a33a29ab2376266 Mon Sep 17 00:00:00 2001 From: mdabrowski Date: Wed, 28 Oct 2026 10:23:41 +0100 Subject: [PATCH 2/7] Fix dockerfile --- .github/php-fedora.Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/php-fedora.Dockerfile b/.github/php-fedora.Dockerfile index 50b42d7..082a694 100644 --- a/.github/php-fedora.Dockerfile +++ b/.github/php-fedora.Dockerfile @@ -7,9 +7,12 @@ FROM ${BASE_IMAGE} ARG LIBMUSTACHE_VERSION WORKDIR /build -RUN dnf groupinstall 'Development Tools' -y +RUN dnf group install 'Development Tools' -y RUN dnf install \ gcc \ + gcc-c++ \ + make \ + git \ automake \ autoconf \ libtool \ @@ -50,4 +53,4 @@ RUN dnf install php-cli -y COPY --from=0 /usr/lib64/php/modules/mustache.so /usr/lib64/php/modules/mustache.so # please forgive me COPY --from=0 /usr/lib64/php/build/run-tests.php /usr/local/lib/php/build/run-tests.php -RUN echo extension=mustache.so | sudo tee /etc/php.d/90-mustache.ini +RUN echo extension=mustache.so | tee /etc/php.d/90-mustache.ini From 8a352bb735e6c028509ce46c3f9af2bf99f3ce06 Mon Sep 17 00:00:00 2001 From: mdabrowski Date: Wed, 28 Oct 2026 10:25:49 +0100 Subject: [PATCH 3/7] Fix dockerfile --- .github/php-fedora.Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/php-fedora.Dockerfile b/.github/php-fedora.Dockerfile index 082a694..cade6eb 100644 --- a/.github/php-fedora.Dockerfile +++ b/.github/php-fedora.Dockerfile @@ -7,7 +7,6 @@ FROM ${BASE_IMAGE} ARG LIBMUSTACHE_VERSION WORKDIR /build -RUN dnf group install 'Development Tools' -y RUN dnf install \ gcc \ gcc-c++ \ From 991dd3712deefe26d949a3d8f1d77d8fe4ba71fa Mon Sep 17 00:00:00 2001 From: mdabrowski Date: Wed, 28 Oct 2026 10:28:36 +0100 Subject: [PATCH 4/7] Fix exception --- mustache_exceptions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mustache_exceptions.cpp b/mustache_exceptions.cpp index bae387c..6e90437 100644 --- a/mustache_exceptions.cpp +++ b/mustache_exceptions.cpp @@ -18,7 +18,7 @@ zend_class_entry * MustacheParserException_ce_ptr; PHP_MINIT_FUNCTION(mustache_exceptions) { try { - zend_class_entry * exception_ce = zend_exception_get_default(); + zend_class_entry * exception_ce = zend_ce_exception; // MustacheException zend_class_entry mustache_exception_ce; From 22b43acb6b8a18ef38b488f50e401e07979889e1 Mon Sep 17 00:00:00 2001 From: mdabrowski Date: Wed, 28 Oct 2026 10:40:16 +0100 Subject: [PATCH 5/7] Fix tests --- mustache_data.cpp | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/mustache_data.cpp b/mustache_data.cpp index 782a091..3ca8775 100644 --- a/mustache_data.cpp +++ b/mustache_data.cpp @@ -327,22 +327,9 @@ static zend_always_inline void mustache_data_from_object_functions_zval(mustache if( ce != NULL ) { data_hash = &ce->function_table; } + // No recursion protection here: the function table is not recursed into, and + // it may live in read-only opcache shared memory (opcache.protect_memory=1) 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) { function_entry = (zend_function *) Z_PTR_P(data_entry); (void)key; /* avoid [-Wunused-but-set-variable] */ @@ -359,15 +346,6 @@ static zend_always_inline void mustache_data_from_object_functions_zval(mustache node->data.insert(std::pair(ckey,child)); } } 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 - } } } /* }}} mustache_data_from_object_functions_zval */ From 038bc3d42af578a1e0223c98f38b9eb5c3695914 Mon Sep 17 00:00:00 2001 From: mdabrowski Date: Wed, 28 Oct 2026 10:48:30 +0100 Subject: [PATCH 6/7] linux.sh fixes --- .github/scripts/linux.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/scripts/linux.sh b/.github/scripts/linux.sh index 1b3acfd..330e7b9 100755 --- a/.github/scripts/linux.sh +++ b/.github/scripts/linux.sh @@ -14,10 +14,20 @@ export SUDO=sudo function install_apt_packages() ( ${SUDO} add-apt-repository ppa:ondrej/php ${SUDO} apt-get update - ${SUDO} apt-get install -y libjson-c-dev libyaml-dev php${PHP_VERSION}-dev lcov + ${SUDO} apt-get install -y libjson-c-dev libyaml-dev php${PHP_VERSION}-cli php${PHP_VERSION}-dev lcov +) + +# the runner image ships its own php, make sure the matrix version is used +function select_php_version() ( + set -o xtrace + ${SUDO} update-alternatives --set php /usr/bin/php${PHP_VERSION} + ${SUDO} update-alternatives --set phpize /usr/bin/phpize${PHP_VERSION} + ${SUDO} update-alternatives --set php-config /usr/bin/php-config${PHP_VERSION} + php --version ) cifold "install apt packages" install_apt_packages +cifold "select php version" select_php_version # source and execute script used in travis source .github/scripts/suite.sh From 152bd4ddb9d8145fc72963f05eb7b6c9a834ed23 Mon Sep 17 00:00:00 2001 From: mdabrowski Date: Wed, 28 Oct 2026 10:52:20 +0100 Subject: [PATCH 7/7] suite.sh fix --- .github/scripts/suite.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/scripts/suite.sh b/.github/scripts/suite.sh index 1019d7e..5e19bf3 100755 --- a/.github/scripts/suite.sh +++ b/.github/scripts/suite.sh @@ -87,8 +87,6 @@ function process_coverage() ( lcov --no-checksum --directory . --capture --compat-libtool --output-file coverage.info lcov --remove coverage.info "/usr*" \ - --remove coverage.info "*/.phpenv/*" \ - --remove coverage.info "/home/travis/build/include/*" \ --compat-libtool \ --output-file coverage.info )