Skip to content

Commit 39a66da

Browse files
authored
Fix imagick patch newer than 30800 (#641)
1 parent 2681a88 commit 39a66da

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/SPC/store/SourcePatcher.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,21 @@ public static function patchImapLicense(): bool
411411
*/
412412
public static function patchImagickWith84(): bool
413413
{
414-
SourcePatcher::patchFile('imagick_php84.patch', SOURCE_PATH . '/php-src/ext/imagick');
415-
return true;
414+
// match imagick version id
415+
$file = SOURCE_PATH . '/php-src/ext/imagick/php_imagick.h';
416+
if (!file_exists($file)) {
417+
return false;
418+
}
419+
$content = file_get_contents($file);
420+
if (preg_match('/#define PHP_IMAGICK_EXTNUM\s+(\d+)/', $content, $match) === 0) {
421+
return false;
422+
}
423+
$extnum = intval($match[1]);
424+
if ($extnum < 30800) {
425+
SourcePatcher::patchFile('imagick_php84_before_30800.patch', SOURCE_PATH . '/php-src/ext/imagick');
426+
return true;
427+
}
428+
return false;
416429
}
417430

418431
public static function patchLibaomForAlpine(): bool

src/globals/test-extensions.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040

4141
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
4242
$extensions = match (PHP_OS_FAMILY) {
43-
'Linux', 'Darwin' => 'openssl,gmssl',
44-
'Windows' => 'gettext',
43+
'Linux', 'Darwin' => 'imagick',
44+
'Windows' => 'bcmath',
4545
};
4646

4747
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).

0 commit comments

Comments
 (0)