From 39a66daf049cf3d0cbb58098298afed4d3481625 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 14 Mar 2025 10:57:33 +0800 Subject: [PATCH] Fix imagick patch newer than 30800 (#641) --- src/SPC/store/SourcePatcher.php | 17 +++++++++++++++-- ...4.patch => imagick_php84_before_30800.patch} | 0 src/globals/test-extensions.php | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) rename src/globals/patch/{imagick_php84.patch => imagick_php84_before_30800.patch} (100%) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 4501fee6..0ff19a93 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -411,8 +411,21 @@ class SourcePatcher */ public static function patchImagickWith84(): bool { - SourcePatcher::patchFile('imagick_php84.patch', SOURCE_PATH . '/php-src/ext/imagick'); - return true; + // match imagick version id + $file = SOURCE_PATH . '/php-src/ext/imagick/php_imagick.h'; + if (!file_exists($file)) { + return false; + } + $content = file_get_contents($file); + if (preg_match('/#define PHP_IMAGICK_EXTNUM\s+(\d+)/', $content, $match) === 0) { + return false; + } + $extnum = intval($match[1]); + if ($extnum < 30800) { + SourcePatcher::patchFile('imagick_php84_before_30800.patch', SOURCE_PATH . '/php-src/ext/imagick'); + return true; + } + return false; } public static function patchLibaomForAlpine(): bool diff --git a/src/globals/patch/imagick_php84.patch b/src/globals/patch/imagick_php84_before_30800.patch similarity index 100% rename from src/globals/patch/imagick_php84.patch rename to src/globals/patch/imagick_php84_before_30800.patch diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index af69ff2f..62a8c724 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -40,8 +40,8 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'openssl,gmssl', - 'Windows' => 'gettext', + 'Linux', 'Darwin' => 'imagick', + 'Windows' => 'bcmath', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).