summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--134.patch151
-rw-r--r--php-pecl-pcov.spec37
-rw-r--r--upstream.patch285
3 files changed, 455 insertions, 18 deletions
diff --git a/134.patch b/134.patch
new file mode 100644
index 0000000..e6e430a
--- /dev/null
+++ b/134.patch
@@ -0,0 +1,151 @@
+From 9e4f26711c0ef1b1d745e7eedc4261b07bca9d1e Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Tue, 21 Jul 2026 15:09:08 +0200
+Subject: [PATCH 1/2] Fix build with PHP 8.6.0alpha2
+
+ . The INI_STR(), INI_INT(), INI_FLT(), and INI_BOOL() macros have been
+ removed. Instead new zend_ini_{bool|long|double|str|string}_literal()
+ macros have been added.
+
+Compatibility macro added for old versions
+
+INI_BOOL used in previous version is zend_ini_long
+It now uses zend_ini_parse_bool with PHP 8.3+
+---
+ pcov.c | 44 +++++++++++++++++++++++++++-----------------
+ 1 file changed, 27 insertions(+), 17 deletions(-)
+
+diff --git a/pcov.c b/pcov.c
+index 06e60ee..411ebf3 100644
+--- a/pcov.c
++++ b/pcov.c
+@@ -57,6 +57,16 @@
+ #define GC_SET_REFCOUNT(ref, rc) (GC_REFCOUNT(ref) = (rc))
+ #endif
+
++#if PHP_VERSION_ID < 80600
++#if PHP_VERSION_ID < 80300
++#define zend_ini_bool_literal(name) ((zend_bool)zend_ini_long((name), sizeof("" name) - 1, 0))
++#else
++#define zend_ini_bool_literal(name) zend_ini_parse_bool(zend_ini_str((name), sizeof("" name) - 1, 0))
++#endif
++#define zend_ini_long_literal(name) zend_ini_long((name), sizeof("" name) - 1, 0)
++#define zend_ini_string_literal(name) zend_ini_string((name), sizeof("" name) - 1, 0)
++#endif
++
+ static zend_always_inline bool php_pcov_api_enabled(void) {
+ const char* env = getenv("PCOV_ENABLED");
+
+@@ -102,7 +112,7 @@ static zend_always_inline bool php_pcov_api_enabled(void) {
+ return false;
+ }
+
+- return INI_BOOL("pcov.enabled");
++ return zend_ini_bool_literal("pcov.enabled");
+ }
+
+ #define PHP_PCOV_API_ENABLED_GUARD() do { \
+@@ -423,7 +433,7 @@ const char *php_pcov_directory_defaults[] = { /* {{{ */
+ NULL
+ }; /* }}} */
+
+-static void php_pcov_setup_directory(char *directory) { /* {{{ */
++static void php_pcov_setup_directory(const char *directory) { /* {{{ */
+ char realpath[MAXPATHLEN];
+ zend_stat_t statbuf;
+
+@@ -448,7 +458,7 @@ static void php_pcov_setup_directory(char *directory) { /* {{{ */
+ PCG(directory) = zend_string_init(directory, strlen(directory), 0);
+ } /* }}} */
+
+-static zend_always_inline void php_pcov_setup_exclude(char *exclude) { /* {{{ */
++static zend_always_inline void php_pcov_setup_exclude(const char *exclude) { /* {{{ */
+ zend_string *pattern;
+
+ if (!exclude || !*exclude) {
+@@ -479,17 +489,17 @@ PHP_RINIT_FUNCTION(pcov)
+ return SUCCESS;
+ }
+
+- PCG(mem) = zend_arena_create(INI_INT("pcov.initial.memory"));
++ PCG(mem) = zend_arena_create(zend_ini_long_literal("pcov.initial.memory"));
+
+- zend_hash_init(&PCG(files), INI_INT("pcov.initial.files"), NULL, php_pcov_files_dtor, 0);
+- zend_hash_init(&PCG(waiting), INI_INT("pcov.initial.files"), NULL, NULL, 0);
+- zend_hash_init(&PCG(ignores), INI_INT("pcov.initial.files"), NULL, NULL, 0);
+- zend_hash_init(&PCG(wants), INI_INT("pcov.initial.files"), NULL, NULL, 0);
+- zend_hash_init(&PCG(discovered), INI_INT("pcov.initial.files"), NULL, ZVAL_PTR_DTOR, 0);
+- zend_hash_init(&PCG(covered), INI_INT("pcov.initial.files"), NULL, php_pcov_covered_dtor, 0);
++ zend_hash_init(&PCG(files), zend_ini_long_literal("pcov.initial.files"), NULL, php_pcov_files_dtor, 0);
++ zend_hash_init(&PCG(waiting), zend_ini_long_literal("pcov.initial.files"), NULL, NULL, 0);
++ zend_hash_init(&PCG(ignores), zend_ini_long_literal("pcov.initial.files"), NULL, NULL, 0);
++ zend_hash_init(&PCG(wants), zend_ini_long_literal("pcov.initial.files"), NULL, NULL, 0);
++ zend_hash_init(&PCG(discovered), zend_ini_long_literal("pcov.initial.files"), NULL, ZVAL_PTR_DTOR, 0);
++ zend_hash_init(&PCG(covered), zend_ini_long_literal("pcov.initial.files"), NULL, php_pcov_covered_dtor, 0);
+
+- php_pcov_setup_directory(INI_STR("pcov.directory"));
+- php_pcov_setup_exclude(INI_STR("pcov.exclude"));
++ php_pcov_setup_directory(zend_ini_string_literal("pcov.directory"));
++ php_pcov_setup_exclude(zend_ini_string_literal("pcov.exclude"));
+
+ #ifdef ZEND_COMPILE_NO_JUMPTABLES
+ CG(compiler_options) |= ZEND_COMPILE_NO_JUMPTABLES;
+@@ -547,8 +557,8 @@ PHP_RSHUTDOWN_FUNCTION(pcov)
+ PHP_MINFO_FUNCTION(pcov)
+ {
+ char info[64];
+- char *directory = INI_STR("pcov.directory");
+- char *exclude = INI_STR("pcov.exclude");
++ const char *directory = zend_ini_string_literal("pcov.directory");
++ const char *exclude = zend_ini_string_literal("pcov.exclude");
+
+ php_info_print_table_start();
+
+@@ -567,13 +577,13 @@ PHP_MINFO_FUNCTION(pcov)
+
+ snprintf(info, sizeof(info),
+ ZEND_LONG_FMT " bytes",
+- (zend_long) INI_INT("pcov.initial.memory"));
++ zend_ini_long_literal("pcov.initial.memory"));
+ php_info_print_table_row(2,
+ "pcov.initial.memory", info);
+
+ snprintf(info, sizeof(info),
+ ZEND_LONG_FMT,
+- (zend_long) INI_INT("pcov.initial.files"));
++ zend_ini_long_literal("pcov.initial.files"));
+ php_info_print_table_row(2,
+ "pcov.initial.files", info);
+
+@@ -862,7 +872,7 @@ PHP_NAMED_FUNCTION(php_pcov_clear)
+
+ PCG(mem) =
+ zend_arena_create(
+- INI_INT("pcov.initial.memory"));
++ zend_ini_long_literal("pcov.initial.memory"));
+
+ PCG(start) = NULL;
+ PCG(last) = NULL;
+
+From f04029fa86ae58c6dfff8049de8433669dbf1394 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Tue, 21 Jul 2026 15:31:30 +0200
+Subject: [PATCH 2/2] fix build with PHP < 8
+
+---
+ pcov.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/pcov.c b/pcov.c
+index 411ebf3..fb7ce56 100644
+--- a/pcov.c
++++ b/pcov.c
+@@ -39,6 +39,8 @@
+ #include "zend_vm_opcodes.h"
+
+ #include "php_pcov.h"
++/* needed for PHP_VERSION_ID < 80000 */
++#include <stdbool.h>
+
+ #define PCOV_FILTER_ALL 0
+ #define PCOV_FILTER_INCLUDE 1
diff --git a/php-pecl-pcov.spec b/php-pecl-pcov.spec
index da18c56..52b56a6 100644
--- a/php-pecl-pcov.spec
+++ b/php-pecl-pcov.spec
@@ -13,26 +13,25 @@
%global pie_proj pcov
%global pecl_name pcov
%global ini_name 40-%{pecl_name}.ini
-%global sources %{archivename}
-%global _configure ../%{sources}/configure
+%global _configure ../configure
# Github forge
%global gh_vend krakjoe
%global gh_proj pcov
%global forgeurl https://github.com/%{gh_vend}/%{gh_proj}
-%global tag v%{version}
-# for EL-8 to avoid TAG usage
-%global archivename %{gh_proj}-%{version}
-Summary: Code coverage driver
Name: %{?scl_prefix}php-pecl-%{pecl_name}
+Summary: Code coverage driver
+License: PHP-3.01
Version: 1.0.12
+Release: 5%{?dist}
%forgemeta
-Release: 4%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
-License: PHP-3.01
URL: %{forgeurl}
Source0: %{forgesource}
+Patch0: upstream.patch
+Patch1: 134.patch
+
BuildRequires: make
BuildRequires: %{?dtsprefix}gcc
BuildRequires: %{?scl_prefix}php-devel >= 7.1
@@ -57,16 +56,16 @@ Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSIO
%prep
-%setup -q -c
+%forgesetup
+%patch -P0 -p1 -b .up
+%patch -P1 -p1 -b .pr
-cd %{sources}
# Sanity check, really often broken
extver=$(sed -n '/#define PHP_PCOV_VERSION/{s/.* "//;s/".*$//;p}' php_pcov.h)
if test "x${extver}" != "x%{version}%{?prever:-%{prever}}"; then
: Error: Upstream extension version is ${extver}, expecting %{version}%{?prever:-%{prever}}.
exit 1
fi
-cd ..
mkdir NTS
%if %{with_zts}
@@ -95,12 +94,11 @@ EOF
%build
%{?dtsenable}
-cd %{sources}
%{__phpize}
[ -f Makefile.global ] && GLOBAL=Makefile.global || GLOBAL=build/Makefile.global
sed -e 's/INSTALL_ROOT/DESTDIR/' -i $GLOBAL
-cd ../NTS
+cd NTS
%configure \
--enable-pcov \
--with-libdir=%{_lib} \
@@ -135,8 +133,6 @@ install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name}
%check
-cd %{sources}
-
: Minimal load test for NTS extension
%{_bindir}/php --no-php-ini \
--define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \
@@ -162,9 +158,9 @@ REPORT_EXIT_STATUS=1 \
%files
-%license %{sources}/LICENSE
-%doc %{sources}/composer.json
-%doc %{sources}/README.md
+%license LICENSE
+%doc composer.json
+%doc README.md
%config(noreplace) %{php_inidir}/%{ini_name}
%{php_extdir}/%{pecl_name}.so
@@ -176,6 +172,11 @@ REPORT_EXIT_STATUS=1 \
%changelog
+* Tue Jul 21 2026 Remi Collet <remi@remirepo.net> - 1.0.12-5
+- support PCOV_ENABLED env using upstream patch
+- fix build with PHP 8.6.0alpha2 using patch from
+ https://github.com/krakjoe/pcov/pull/134
+
* Thu Mar 12 2026 Remi Collet <remi@remirepo.net> - 1.0.12-4
- drop pear/pecl dependency
- sources from github
diff --git a/upstream.patch b/upstream.patch
new file mode 100644
index 0000000..e07990c
--- /dev/null
+++ b/upstream.patch
@@ -0,0 +1,285 @@
+From f7e9f7b2675aaf54f5babaac3e32112c2bae2292 Mon Sep 17 00:00:00 2001
+From: Joe Watkins <krakjoe@php.net>
+Date: Mon, 15 Sep 2025 10:28:07 +0200
+Subject: [PATCH] PCOV_ENABLED env support
+
+---
+ pcov.c | 71 +++++++++++++++++++++++++++++++++++++++++++++-----
+ tests/008.phpt | 16 ++++++++++++
+ tests/009.phpt | 16 ++++++++++++
+ tests/010.phpt | 16 ++++++++++++
+ tests/011.phpt | 16 ++++++++++++
+ tests/012.phpt | 16 ++++++++++++
+ tests/013.phpt | 16 ++++++++++++
+ 7 files changed, 161 insertions(+), 6 deletions(-)
+ create mode 100644 tests/008.phpt
+ create mode 100644 tests/009.phpt
+ create mode 100644 tests/010.phpt
+ create mode 100644 tests/011.phpt
+ create mode 100644 tests/012.phpt
+ create mode 100644 tests/013.phpt
+
+diff --git a/pcov.c b/pcov.c
+index ba58263..06e60ee 100644
+--- a/pcov.c
++++ b/pcov.c
+@@ -57,8 +57,56 @@
+ #define GC_SET_REFCOUNT(ref, rc) (GC_REFCOUNT(ref) = (rc))
+ #endif
+
++static zend_always_inline bool php_pcov_api_enabled(void) {
++ const char* env = getenv("PCOV_ENABLED");
++
++ if (env) {
++ size_t length = strlen(env);
++
++ if (length == 1) {
++ switch (*env) {
++ case '1':
++ case 'y': /* short yes */
++ return true;
++ case '0':
++ case 'n': /* short no */
++ return false;
++ }
++ /* all other characters are assumed false */
++ return false;
++ }
++
++ if (length == 2) {
++ if (strncasecmp(env, ZEND_STRL("on")) == SUCCESS) {
++ return true;
++ } else if (strncasecmp(env, ZEND_STRL("no")) == SUCCESS) {
++ return false;
++ }
++
++ /* all other strings are assumed false */
++ return false;
++ }
++
++ if (length == 3) {
++ if (strncasecmp(env, ZEND_STRL("off")) == SUCCESS) {
++ return false;
++ } else if (strncasecmp(env, ZEND_STRL("yes")) == SUCCESS) {
++ return true;
++ }
++
++ /* all other strings are assumed false */
++ return false;
++ }
++
++ /* all other lengths are assumed false */
++ return false;
++ }
++
++ return INI_BOOL("pcov.enabled");
++}
++
+ #define PHP_PCOV_API_ENABLED_GUARD() do { \
+- if (!INI_BOOL("pcov.enabled")) { \
++ if (!php_pcov_api_enabled()) { \
+ return; \
+ } \
+ } while (0);
+@@ -339,7 +387,7 @@ PHP_MINIT_FUNCTION(pcov)
+
+ REGISTER_INI_ENTRIES();
+
+- if (INI_BOOL("pcov.enabled")) {
++ if (php_pcov_api_enabled()) {
+ zend_execute_ex_function = zend_execute_ex;
+ zend_execute_ex = php_pcov_execute_ex;
+ }
+@@ -357,7 +405,7 @@ PHP_MINIT_FUNCTION(pcov)
+ */
+ PHP_MSHUTDOWN_FUNCTION(pcov)
+ {
+- if (INI_BOOL("pcov.enabled")) {
++ if (php_pcov_api_enabled()) {
+ zend_execute_ex = zend_execute_ex_function;
+ }
+
+@@ -427,7 +475,7 @@ PHP_RINIT_FUNCTION(pcov)
+ ZEND_TSRMLS_CACHE_UPDATE();
+ #endif
+
+- if (!INI_BOOL("pcov.enabled")) {
++ if (!php_pcov_api_enabled()) {
+ return SUCCESS;
+ }
+
+@@ -464,7 +512,7 @@ PHP_RINIT_FUNCTION(pcov)
+ */
+ PHP_RSHUTDOWN_FUNCTION(pcov)
+ {
+- if (!INI_BOOL("pcov.enabled") || CG(unclean_shutdown)) {
++ if (!php_pcov_api_enabled() || CG(unclean_shutdown)) {
+ return SUCCESS;
+ }
+
+@@ -506,7 +554,7 @@ PHP_MINFO_FUNCTION(pcov)
+
+ php_info_print_table_header(2,
+ "PCOV support",
+- INI_BOOL("pcov.enabled") ? "Enabled" : "Disabled");
++ php_pcov_api_enabled() ? "Enabled" : "Disabled");
+ php_info_print_table_row(2,
+ "PCOV version",
+ PHP_PCOV_VERSION);
+@@ -862,6 +910,16 @@ PHP_NAMED_FUNCTION(php_pcov_memory)
+ } while ((arena = arena->prev));
+ } /* }}} */
+
++/* {{{ bool \pcov\enabled(void) */
++PHP_NAMED_FUNCTION(php_pcov_enabled)
++{
++ if (zend_parse_parameters_none() != SUCCESS) {
++ return;
++ }
++
++ RETURN_BOOL(php_pcov_api_enabled());
++} /* }}} */
++
+ /* {{{ */
+ ZEND_BEGIN_ARG_INFO_EX(php_pcov_collect_arginfo, 0, 0, 0)
+ ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
+@@ -886,6 +944,7 @@ const zend_function_entry php_pcov_functions[] = {
+ ZEND_NS_FENTRY("pcov", clear, php_pcov_clear, php_pcov_clear_arginfo, 0)
+ ZEND_NS_FENTRY("pcov", waiting, php_pcov_waiting, php_pcov_no_arginfo, 0)
+ ZEND_NS_FENTRY("pcov", memory, php_pcov_memory, php_pcov_no_arginfo, 0)
++ ZEND_NS_FENTRY("pcov", enabled, php_pcov_enabled, php_pcov_no_arginfo, 0)
+ PHP_FE_END
+ };
+ /* }}} */
+diff --git a/tests/008.phpt b/tests/008.phpt
+new file mode 100644
+index 0000000..0985bad
+--- /dev/null
++++ b/tests/008.phpt
+@@ -0,0 +1,16 @@
++--TEST--
++enable/disable (disable env as no)
++--SKIPIF--
++<?php if (!extension_loaded("pcov")) print "skip"; ?>
++--INI--
++pcov.enabled = 1
++--ENV--
++PCOV_ENABLED=no
++--FILE--
++<?php
++var_dump(\getenv("PCOV_ENABLED"));
++var_dump(\pcov\enabled());
++?>
++--EXPECT--
++string(2) "no"
++bool(false)
+diff --git a/tests/009.phpt b/tests/009.phpt
+new file mode 100644
+index 0000000..b174b2f
+--- /dev/null
++++ b/tests/009.phpt
+@@ -0,0 +1,16 @@
++--TEST--
++enable/disable (enable env as yes)
++--SKIPIF--
++<?php if (!extension_loaded("pcov")) print "skip"; ?>
++--INI--
++pcov.enabled = 0
++--ENV--
++PCOV_ENABLED=yes
++--FILE--
++<?php
++var_dump(\getenv("PCOV_ENABLED"));
++var_dump(\pcov\enabled());
++?>
++--EXPECT--
++string(3) "yes"
++bool(true)
+diff --git a/tests/010.phpt b/tests/010.phpt
+new file mode 100644
+index 0000000..a97e320
+--- /dev/null
++++ b/tests/010.phpt
+@@ -0,0 +1,16 @@
++--TEST--
++enable/disable (disable env as off)
++--SKIPIF--
++<?php if (!extension_loaded("pcov")) print "skip"; ?>
++--INI--
++pcov.enabled = 1
++--ENV--
++PCOV_ENABLED=off
++--FILE--
++<?php
++var_dump(\getenv("PCOV_ENABLED"));
++var_dump(\pcov\enabled());
++?>
++--EXPECT--
++string(3) "off"
++bool(false)
+diff --git a/tests/011.phpt b/tests/011.phpt
+new file mode 100644
+index 0000000..8775c8c
+--- /dev/null
++++ b/tests/011.phpt
+@@ -0,0 +1,16 @@
++--TEST--
++enable/disable (enable env as on)
++--SKIPIF--
++<?php if (!extension_loaded("pcov")) print "skip"; ?>
++--INI--
++pcov.enabled = 0
++--ENV--
++PCOV_ENABLED=on
++--FILE--
++<?php
++var_dump(\getenv("PCOV_ENABLED"));
++var_dump(\pcov\enabled());
++?>
++--EXPECT--
++string(2) "on"
++bool(true)
+diff --git a/tests/012.phpt b/tests/012.phpt
+new file mode 100644
+index 0000000..24fb998
+--- /dev/null
++++ b/tests/012.phpt
+@@ -0,0 +1,16 @@
++--TEST--
++enable/disable (disable env as 0)
++--SKIPIF--
++<?php if (!extension_loaded("pcov")) print "skip"; ?>
++--INI--
++pcov.enabled = 1
++--ENV--
++PCOV_ENABLED=0
++--FILE--
++<?php
++var_dump(\getenv("PCOV_ENABLED"));
++var_dump(\pcov\enabled());
++?>
++--EXPECT--
++string(1) "0"
++bool(false)
+diff --git a/tests/013.phpt b/tests/013.phpt
+new file mode 100644
+index 0000000..f3c59c5
+--- /dev/null
++++ b/tests/013.phpt
+@@ -0,0 +1,16 @@
++--TEST--
++enable/disable (enable env as 1)
++--SKIPIF--
++<?php if (!extension_loaded("pcov")) print "skip"; ?>
++--INI--
++pcov.enabled = 0
++--ENV--
++PCOV_ENABLED=1
++--FILE--
++<?php
++var_dump(\getenv("PCOV_ENABLED"));
++var_dump(\pcov\enabled());
++?>
++--EXPECT--
++string(1) "1"
++bool(true)