Commit 7727193818c for php.net
commit 7727193818cd8e515a459dd97f854d1abbe2e66a
Author: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Date: Sun May 24 19:37:34 2026 +0200
zlib: fix test skipif sections (#22099)
Depending on the specific PHP configuration, the regex matching for the
version number in get_zlib_version() can fail.
On master, this results in deprecation warnings and subsequent test
borks:
```
Deprecated: version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated in /work/php-src/ext/zlib/tests/gzgetc_basic.skip.php on line 3 [/work/php-src/ext/zlib/tests/gzgetc_basic.phpt]
Deprecated: version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated in /work/php-src/ext/zlib/tests/gzgetc_basic_1.skip.php on line 4
```
Since ZLIB_VERSION is a constant containing the version as a string,
remove all this nonsense and just use the constant directly.
diff --git a/ext/zlib/tests/bug55544-win.phpt b/ext/zlib/tests/bug55544-win.phpt
index 5c94236a2f2..02a1ac83700 100644
Binary files a/ext/zlib/tests/bug55544-win.phpt and b/ext/zlib/tests/bug55544-win.phpt differ
diff --git a/ext/zlib/tests/func.inc b/ext/zlib/tests/func.inc
deleted file mode 100644
index 73cfc4e06ff..00000000000
--- a/ext/zlib/tests/func.inc
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-function get_zlib_version()
-{
- $version = NULL;
-
- ob_start();
- phpinfo();
- $info = ob_get_contents();
- ob_end_clean();
- //if (preg_match(',zlib.*Compiled Version => (\d+\.\d+\.\d+),s', $info, $match)) {
- // $version = $match[1];
- if (preg_match(',zlib(?!.*libXML).*Compiled Version (=> |</).*(\d+\.\d+\.\d+?),sU', $info, $match)) {
- $version = $match[2];
- }
-
- return $version;
-}
diff --git a/ext/zlib/tests/gzencode_variation2-win32.phpt b/ext/zlib/tests/gzencode_variation2-win32.phpt
index 90da1244158..34ec5b3b366 100644
--- a/ext/zlib/tests/gzencode_variation2-win32.phpt
+++ b/ext/zlib/tests/gzencode_variation2-win32.phpt
@@ -9,11 +9,8 @@
die("skip.. only for Windows");
}
-
-
-include 'func.inc';
-if (version_compare(get_zlib_version(), "1.2.11") < 0) {
- die("skip - at least zlib 1.2.11 required, got " . get_zlib_version());
+if (version_compare(ZLIB_VERSION, "1.2.11") < 0) {
+ die("skip - at least zlib 1.2.11 required, got " . ZLIB_VERSION);
}
?>
--FILE--
diff --git a/ext/zlib/tests/gzgetc_basic.phpt b/ext/zlib/tests/gzgetc_basic.phpt
index 7164c23098d..3a2fbe066e9 100644
--- a/ext/zlib/tests/gzgetc_basic.phpt
+++ b/ext/zlib/tests/gzgetc_basic.phpt
@@ -4,9 +4,7 @@
zlib
--SKIPIF--
<?php
-
-include 'func.inc';
-if (version_compare(get_zlib_version(), '1.2.5') > 0) {
+if (version_compare(ZLIB_VERSION, '1.2.5') > 0) {
die('skip - only for zlib <= 1.2.5');
}
?>
diff --git a/ext/zlib/tests/gzgetc_basic_1.phpt b/ext/zlib/tests/gzgetc_basic_1.phpt
index e70c5814fcb..91c3a763857 100644
--- a/ext/zlib/tests/gzgetc_basic_1.phpt
+++ b/ext/zlib/tests/gzgetc_basic_1.phpt
@@ -4,9 +4,7 @@
zlib
--SKIPIF--
<?php
-
-include 'func.inc';
-if (version_compare(get_zlib_version(), '1.2.7') < 0) {
+if (version_compare(ZLIB_VERSION, '1.2.7') < 0) {
die('skip - only for zlib >= 1.2.7');
}
?>