From 584b39db5c3d09d2dbb0b12b77a9314b4314f02b Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 9 Jun 2021 10:43:34 +0200 Subject: add patches for PHP 8.1 from upstream and from https://github.com/Imagick/imagick/pull/413 run tests in parallel (7.4+) --- 375.patch | 22 ++++ imagick-php81.patch | 287 ++++++++++++++++++++++++++++++++++++++++++++++++++ php-pecl-imagick.spec | 16 ++- 3 files changed, 324 insertions(+), 1 deletion(-) create mode 100644 imagick-php81.patch diff --git a/375.patch b/375.patch index 80d138d..53d6b1c 100644 --- a/375.patch +++ b/375.patch @@ -88,3 +88,25 @@ index dfb73a1..b92db01 100644 PHP_SUBST(IMAGICK_SHARED_LIBADD) AC_DEFINE(HAVE_IMAGICK,1,[ ]) +From d507dd74ee46ca8db0b659e4151f5e5440056aca Mon Sep 17 00:00:00 2001 +From: Danack +Date: Mon, 7 Jun 2021 22:01:14 +0100 +Subject: [PATCH] Tpyo. + +--- + config.m4 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/config.m4 b/config.m4 +index 9037f7ab..d1310a3e 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -68,7 +68,7 @@ IM_FIND_IMAGEMAGICK([6.2.4], [$PHP_IMAGICK]) + ]])],[ + AC_MSG_RESULT(yes) + PHP_CHECK_FUNC(omp_pause_resource_all, gomp) +- PHP_ADD_LIBRARY(gomp,, GMAGICK_SHARED_LIBADD) ++ PHP_ADD_LIBRARY(gomp,, IMAGICK_SHARED_LIBADD) + ],[ + AC_MSG_RESULT(no) + ]) diff --git a/imagick-php81.patch b/imagick-php81.patch new file mode 100644 index 0000000..8a799fe --- /dev/null +++ b/imagick-php81.patch @@ -0,0 +1,287 @@ +From 81cc92ec24549c86be875b1a9977419a76f3471d Mon Sep 17 00:00:00 2001 +From: Danack +Date: Sat, 5 Jun 2021 15:25:05 +0100 +Subject: [PATCH] Add ifdef for PHP 8.1 + +--- + imagick.c | 2 +- + php_imagick_defs.h | 5 +++++ + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/imagick.c b/imagick.c +index f7a94ae0..d2cf9fef 100644 +--- a/imagick.c ++++ b/imagick.c +@@ -3829,7 +3829,7 @@ PHP_MINIT_FUNCTION(imagick) + #endif + + php_imagick_sc_entry = zend_register_internal_class(&ce TSRMLS_CC); +- zend_class_implements(php_imagick_sc_entry TSRMLS_CC, 2, zend_ce_iterator, spl_ce_Countable); ++ zend_class_implements(php_imagick_sc_entry TSRMLS_CC, 2, zend_ce_iterator, im_ce_countable); + + /* + Initialize the class (ImagickDraw) +diff --git a/php_imagick_defs.h b/php_imagick_defs.h +index 859f35df..6017b33c 100644 +--- a/php_imagick_defs.h ++++ b/php_imagick_defs.h +@@ -79,6 +79,11 @@ + #define im_long long + #endif + ++#if PHP_VERSION_ID >= 80100 ++ #define im_ce_countable zend_ce_countable ++#else ++ #define im_ce_countable spl_ce_Countable ++#endif + + typedef struct _php_imagick_callback { + void ***thread_ctx; +From 9a48afcca65beed794dee3da15eef9c077eba487 Mon Sep 17 00:00:00 2001 +From: Danack +Date: Sat, 5 Jun 2021 15:43:03 +0100 +Subject: [PATCH] Explicit casts to make php 8.1 happy. + +--- + tests/244_Tutorial_psychedelicFontGif_basic.phpt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/244_Tutorial_psychedelicFontGif_basic.phpt b/tests/244_Tutorial_psychedelicFontGif_basic.phpt +index 3fde1d74..a1bd1d98 100644 +--- a/tests/244_Tutorial_psychedelicFontGif_basic.phpt ++++ b/tests/244_Tutorial_psychedelicFontGif_basic.phpt +@@ -34,7 +34,7 @@ function psychedelicFontGif($name = 'Danack') { + $draw->setStrokeColor($color); + $draw->setFillColor($color); + $draw->setStrokeWidth($strokeWidth * 3 * $scale); +- $draw->annotation(60 * $scale, 165 * $scale, $name); ++ $draw->annotation((int)(60 * $scale), (int)(165 * $scale), $name); + } + + $draw->setStrokeColor('none'); +@@ -44,7 +44,7 @@ function psychedelicFontGif($name = 'Danack') { + + //Create an image object which the draw commands can be rendered into + $imagick = new \Imagick(); +- $imagick->newImage(650 * $scale, 230 * $scale, "#eee"); ++ $imagick->newImage((int)(650 * $scale), (int)(230 * $scale), "#eee"); + $imagick->setImageFormat("png"); + + //Render the draw commands in the ImagickDraw object +From a6ff2498e3f4cd1f9a200d5695dfddba458a9064 Mon Sep 17 00:00:00 2001 +From: Danack +Date: Sat, 5 Jun 2021 15:44:17 +0100 +Subject: [PATCH] Explicit casts to make php 8.1 happy. + +--- + tests/245_Tutorial_screenEmbed_basic.phpt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/245_Tutorial_screenEmbed_basic.phpt b/tests/245_Tutorial_screenEmbed_basic.phpt +index e25229da..36b9fbcf 100644 +--- a/tests/245_Tutorial_screenEmbed_basic.phpt ++++ b/tests/245_Tutorial_screenEmbed_basic.phpt +@@ -33,7 +33,7 @@ function screenEmbed() { + $overlay->modulateImage(97, 100, 0); + $overlay->distortImage(\Imagick::DISTORTION_PERSPECTIVE, $points, true); + +- $imagick->compositeImage($overlay, \Imagick::COMPOSITE_OVER, 364.5 - $offset, 23.5); ++ $imagick->compositeImage($overlay, \Imagick::COMPOSITE_OVER, (int)(364.5 - $offset), 23); + + $bytes = $imagick->getImageBlob(); + if (strlen($bytes) <= 0) { echo "Failed to generate image.";} +From 8d550128a271b2d6659e81b023e25b2ed0b787fa Mon Sep 17 00:00:00 2001 +From: Danack +Date: Sat, 5 Jun 2021 15:46:21 +0100 +Subject: [PATCH] Explicit casts to make php 8.1 happy. + +--- + tests/049_Imagick_deskewImage_basic.phpt | 7 ++++++- + tests/110_Imagick_resizeImage_basic.phpt | 4 ++-- + 2 files changed, 8 insertions(+), 3 deletions(-) + +diff --git a/tests/049_Imagick_deskewImage_basic.phpt b/tests/049_Imagick_deskewImage_basic.phpt +index 96364c2b..0ec546f2 100644 +--- a/tests/049_Imagick_deskewImage_basic.phpt ++++ b/tests/049_Imagick_deskewImage_basic.phpt +@@ -26,7 +26,12 @@ function deskewImage($threshold) { + $deskewImagick->cropImage($deskewImagick->getImageWidth() - $trim, $deskewImagick->getImageHeight(), $trim, 0); + $imagick->cropImage($imagick->getImageWidth() - $trim, $imagick->getImageHeight(), $trim, 0); + $deskewImagick->resizeimage($deskewImagick->getImageWidth() / 2, $deskewImagick->getImageHeight() / 2, \Imagick::FILTER_LANCZOS, 1); +- $imagick->resizeimage($imagick->getImageWidth() / 2, $imagick->getImageHeight() / 2, \Imagick::FILTER_LANCZOS, 1); ++ $imagick->resizeimage( ++ (int)($imagick->getImageWidth() / 2), ++ (int)($imagick->getImageHeight() / 2), ++ \Imagick::FILTER_LANCZOS, ++ 1 ++ ); + $newCanvas = new \Imagick(); + $newCanvas->newimage($imagick->getImageWidth() + $deskewImagick->getImageWidth() + 20, $imagick->getImageHeight(), 'red', 'jpg'); + $newCanvas->compositeimage($imagick, \Imagick::COMPOSITE_COPY, 5, 0); +diff --git a/tests/110_Imagick_resizeImage_basic.phpt b/tests/110_Imagick_resizeImage_basic.phpt +index c800e5fa..0628afb4 100644 +--- a/tests/110_Imagick_resizeImage_basic.phpt ++++ b/tests/110_Imagick_resizeImage_basic.phpt +@@ -32,8 +32,8 @@ function resizeImage($width, $height, $filterType, $blur, $bestFit, $cropZoom) { + $imagick->cropimage( + $newWidth, + $newHeight, +- ($cropWidth - $newWidth) / 2, +- ($cropHeight - $newHeight) / 2 ++ (int)(($cropWidth - $newWidth) / 2), ++ (int)(($cropHeight - $newHeight) / 2) + ); + + $imagick->scaleimage( +From c7578c71285fb11d129abb7b9781c91db91f93da Mon Sep 17 00:00:00 2001 +From: Danack +Date: Sat, 5 Jun 2021 19:23:29 +0100 +Subject: [PATCH] Fix parsing of nullable long parameters. + +--- + imagick_class.c | 15 +++++++++++++-- + runTests.sh | 7 +++++-- + 2 files changed, 18 insertions(+), 4 deletions(-) + +diff --git a/imagick_class.c b/imagick_class.c +index 23e42de0..9a390f2b 100644 +--- a/imagick_class.c ++++ b/imagick_class.c +@@ -7855,13 +7855,24 @@ zend_bool s_resize_bounding_box(MagickWand *magick_wand, im_long box_width, im_l + */ + PHP_METHOD(imagick, thumbnailimage) + { +- im_long width, height, new_width, new_height; ++ im_long width = 0, height = 0, new_width, new_height; + php_imagick_object *intern; + zend_bool bestfit = 0, fill = 0; + zend_bool legacy = 0; + ++ // Changing longs to be nullable "l!", means that zpp ++ // wants to write whether they were null to a variable. ++ bool width_is_null = 1; ++ bool height_is_null = 1; ++ ++ + /* Parse parameters given to function */ +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|bbb", &width, &height, &bestfit, &fill, &legacy) == FAILURE) { ++ if (zend_parse_parameters( ++ ZEND_NUM_ARGS() TSRMLS_CC, ++ "l!l!|bbb", ++ &width, &width_is_null, ++ &height, &height_is_null, ++ &bestfit, &fill, &legacy) == FAILURE) { + return; + } + + +From 212de567ef514e2a07f0c55502fe7ceb66ece6a7 Mon Sep 17 00:00:00 2001 +From: Danack +Date: Sat, 5 Jun 2021 19:46:41 +0100 +Subject: [PATCH] Wrap param parsing to use old method, until versions that + don't require a compiler that understands bools are dropped. + +--- + imagick_class.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/imagick_class.c b/imagick_class.c +index 9a390f2b..2f9e6909 100644 +--- a/imagick_class.c ++++ b/imagick_class.c +@@ -7860,11 +7860,16 @@ PHP_METHOD(Imagick, thumbnailImage) + zend_bool bestfit = 0, fill = 0; + zend_bool legacy = 0; + ++#if PHP_VERSION_ID < 80100 ++ // This uses an implicit conversion of null to 0 for longs ++ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|bbb", &width, &height, &bestfit, &fill, &legacy) == FAILURE) { ++ return; ++ } ++#else + // Changing longs to be nullable "l!", means that zpp + // wants to write whether they were null to a variable. +- bool width_is_null = 1; +- bool height_is_null = 1; +- ++ bool width_is_null = 0; ++ bool height_is_null = 0; + + /* Parse parameters given to function */ + if (zend_parse_parameters( +@@ -7875,6 +7880,7 @@ PHP_METHOD(Imagick, thumbnailImage) + &bestfit, &fill, &legacy) == FAILURE) { + return; + } ++#endif + + intern = Z_IMAGICK_P(getThis()); + if (php_imagick_ensure_not_empty (intern->magick_wand) == 0) +From 78c9daa8bfc56aa5806b062ee5605f57e81f063e Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 9 Jun 2021 09:39:25 +0200 +Subject: [PATCH 1/2] get rid of ZVAL_NEW_ARR + +--- + imagick_class.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/imagick_class.c b/imagick_class.c +index e041f4e..2254313 100644 +--- a/imagick_class.c ++++ b/imagick_class.c +@@ -6841,7 +6841,6 @@ PHP_METHOD(Imagick, getImageChannelStatistics) + #if MagickLibVersion >= 0x700 + for (i=0; i < sizeof(channels)/sizeof(channels[0]); i++) { + #ifdef ZEND_ENGINE_3 +- ZVAL_NEW_ARR(&tmp); + array_init(&tmp); + add_assoc_double(&tmp, "mean", statistics[i].mean); + add_assoc_double(&tmp, "minima", statistics[i].minima); +@@ -6869,7 +6868,6 @@ PHP_METHOD(Imagick, getImageChannelStatistics) + #else //below MagickLibVersion>= 0x700 + for (i = 0; i < elements ; i++) { + #ifdef ZEND_ENGINE_3 +- ZVAL_NEW_ARR(&tmp); + array_init(&tmp); + add_assoc_double(&tmp, "mean", statistics[channels[i]].mean); + add_assoc_double(&tmp, "minima", statistics[channels[i]].minima); +@@ -8703,7 +8701,7 @@ PHP_METHOD(Imagick, identifyImage) + // Geometry is an associative array + + #ifdef ZEND_ENGINE_3 +- ZVAL_NEW_ARR(&array); ++ array_init(&array); + pArray = &array; + #else + MAKE_STD_ZVAL(array); + +From 3c387a2b1a0b3a9cc08f878a2541b814f3b831bf Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 9 Jun 2021 09:40:16 +0200 +Subject: [PATCH 2/2] fix Implicit conversion + +--- + tests/172_ImagickPixel_setColorValueQuantum_basic.phpt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/172_ImagickPixel_setColorValueQuantum_basic.phpt b/tests/172_ImagickPixel_setColorValueQuantum_basic.phpt +index e69108e..bf68edf 100644 +--- a/tests/172_ImagickPixel_setColorValueQuantum_basic.phpt ++++ b/tests/172_ImagickPixel_setColorValueQuantum_basic.phpt +@@ -13,7 +13,7 @@ function setColorValueQuantum() { + + $draw = new \ImagickDraw(); + $color = new \ImagickPixel('blue'); +- $color->setcolorValueQuantum(\Imagick::COLOR_RED, 128 * $quantumRange['quantumRangeLong'] / 256); ++ $color->setcolorValueQuantum(\Imagick::COLOR_RED, (int)(128 * $quantumRange['quantumRangeLong'] / 256)); + + $draw->setstrokewidth(1.0); + $draw->setStrokeColor($color); +@@ -33,4 +33,4 @@ setColorValueQuantum() ; + echo "Ok"; + ?> + --EXPECTF-- +-Ok +\ No newline at end of file ++Ok diff --git a/php-pecl-imagick.spec b/php-pecl-imagick.spec index 96cebdf..2399ecf 100644 --- a/php-pecl-imagick.spec +++ b/php-pecl-imagick.spec @@ -39,7 +39,7 @@ Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}} Release: 0.9.%{gh_date}git%{gh_short}%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{pecl_name}-%{version}-%{gh_short}.tar.gz %else -Release: 17%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 18%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Source0: https://pecl.php.net/get/%{pecl_name}-%{upstream_version}%{?upstream_prever}.tgz %endif License: PHP @@ -51,6 +51,7 @@ Patch2: https://patch-diff.githubusercontent.com/raw/Imagick/imagick/pull Patch3: https://patch-diff.githubusercontent.com/raw/Imagick/imagick/pull/348.patch Patch4: https://patch-diff.githubusercontent.com/raw/Imagick/imagick/pull/350.patch Patch5: https://patch-diff.githubusercontent.com/raw/Imagick/imagick/pull/375.patch +Patch6: %{pecl_name}-php81.patch BuildRequires: make BuildRequires: %{?dtsprefix}gcc @@ -119,6 +120,9 @@ Obsoletes: php74-pecl-%{pecl_name} <= %{version} %if "%{php_version}" > "8.0" Obsoletes: php80-pecl-%{pecl_name} <= %{version} %endif +%if "%{php_version}" > "8.1" +Obsoletes: php81-pecl-%{pecl_name} <= %{version} +%endif %endif @@ -172,6 +176,7 @@ cd NTS %patch3 -p1 -b .pr348 %patch4 -p1 -b .pr350 %patch5 -p1 -b .pr375 +%patch6 -p1 -b .php81 extver=$(sed -n '/#define PHP_IMAGICK_VERSION/{s/.* "//;s/".*$//;p}' php_imagick.h) if test "x${extver}" != "x%{upstream_version}%{?upstream_prever}"; then @@ -287,7 +292,11 @@ cd NTS : upstream test suite for NTS extension TEST_PHP_EXECUTABLE=%{__php} \ TEST_PHP_ARGS="-n -d extension=%{buildroot}%{php_extdir}/%{pecl_name}.so" \ +%if "%{php_version}" > "7.4" +%{__php} -n run-tests.php -q --show-diff %{?_smp_mflags} +%else %{__php} -n run-tests.php -q --show-diff +%endif %if %{with_zts} : simple module load test for ZTS extension @@ -322,6 +331,11 @@ cd ../ZTS %changelog +* Wed Jun 9 2021 Remi Collet - 3.4.4-18 +- add patches for PHP 8.1 from upstream and from + https://github.com/Imagick/imagick/pull/413 +- run tests in parallel (7.4+) + * Mon Feb 22 2021 Remi Collet - 3.4.4-17 - build against ImageMagick6 and new soname -- cgit