Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/php-fedora.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ FROM ${BASE_IMAGE}
ARG LIBMUSTACHE_VERSION
WORKDIR /build

RUN dnf groupinstall 'Development Tools' -y
RUN dnf install \
gcc \
gcc-c++ \
make \
git \
automake \
autoconf \
libtool \
Expand Down Expand Up @@ -50,4 +52,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
12 changes: 11 additions & 1 deletion .github/scripts/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions .github/scripts/suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
19 changes: 19 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
}
26 changes: 2 additions & 24 deletions mustache_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] */
Expand All @@ -359,15 +346,6 @@ static zend_always_inline void mustache_data_from_object_functions_zval(mustache
node->data.insert(std::pair<std::string,mustache::Data*>(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 */
Expand Down
2 changes: 1 addition & 1 deletion mustache_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading