diff options
author | Remi Collet <remi@remirepo.net> | 2021-01-25 14:38:18 +0100 |
---|---|---|
committer | Remi Collet <remi@remirepo.net> | 2021-01-25 14:38:18 +0100 |
commit | 3322d6726dd05b802c88f01696939b99c4497582 (patch) | |
tree | b45445f9ea1b1a9f68b21e0abefb7ee7e1ce407f | |
parent | 52def9e3f3ce94fb33f2561b6a978b58a1a456e7 (diff) |
add patch for PHP 8 from
https://github.com/vitoc/gmagick/pull/50
add build fixes from
https://github.com/rlerdorf/gmagick/pull/1
https://github.com/rlerdorf/gmagick/pull/2
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | 1.patch | 184 | ||||
-rw-r--r-- | 2.patch | 29 | ||||
-rw-r--r-- | 50.patch | 439 | ||||
-rw-r--r-- | gmagick-bug78465.patch | 29 | ||||
-rw-r--r-- | php-pecl-gmagick.spec | 49 | ||||
-rw-r--r-- | skipif.inc | 12 |
7 files changed, 692 insertions, 52 deletions
@@ -1,5 +1,7 @@ +clog package-*.xml *.tgz +*.tar.bz2 *.tar.gz *.tar.xz *.tar.xz.asc @@ -0,0 +1,184 @@ +From 9602d4c228eaed59d20de94e809ff3827f1e6602 Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Mon, 25 Jan 2021 08:08:55 +0100 +Subject: [PATCH 1/6] fix [-Wmisleading-indentation] + +--- + gmagick_methods.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gmagick_methods.c b/gmagick_methods.c +index 39c48a4..d2b95a5 100644 +--- a/gmagick_methods.c ++++ b/gmagick_methods.c +@@ -4546,7 +4546,7 @@ PHP_METHOD(gmagick, unsharpmaskimage) + if (php_gmagick_ensure_not_empty (intern->magick_wand) == 0) + return; + +- status = MagickUnsharpMaskImage(intern->magick_wand, radius, sigma, amount, threshold); ++ status = MagickUnsharpMaskImage(intern->magick_wand, radius, sigma, amount, threshold); + + if (status == MagickFalse) { + GMAGICK_THROW_GMAGICK_EXCEPTION(intern->magick_wand, "Unable to unsharp mask image"); + +From feb41650a583f3fa625e4e69493209b10d69f45b Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Mon, 25 Jan 2021 08:11:45 +0100 +Subject: [PATCH 2/6] fix [-Wformat=] + +--- + gmagickpixel_methods.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/gmagickpixel_methods.c b/gmagickpixel_methods.c +index 88d8fb2..121a8fb 100644 +--- a/gmagickpixel_methods.c ++++ b/gmagickpixel_methods.c +@@ -330,7 +330,7 @@ PHP_METHOD(gmagickpixel, getcolorvaluequantum) + break; + + default: +- zend_throw_exception_ex(php_gmagickpixel_exception_class_entry, 2 TSRMLS_CC, "Unknown color type: %d", color_quantum); ++ zend_throw_exception_ex(php_gmagickpixel_exception_class_entry, 2 TSRMLS_CC, "Unknown color type: " ZEND_LONG_FMT, color_quantum); + RETURN_NULL(); + } + RETVAL_LONG(color_value_quantum); +@@ -391,10 +391,10 @@ PHP_METHOD(gmagickpixel, setcolorvaluequantum) + break; + + default: +- zend_throw_exception_ex(php_gmagickpixel_exception_class_entry, 2 TSRMLS_CC, "Unknown color type: %d", color_quantum); ++ zend_throw_exception_ex(php_gmagickpixel_exception_class_entry, 2 TSRMLS_CC, "Unknown color type: " ZEND_LONG_FMT, color_quantum); + RETURN_NULL(); + } + + GMAGICK_CHAIN_METHOD; + } +-/* }}} */ +\ No newline at end of file ++/* }}} */ + +From 59f93c789f2a96c433e4ee5f47c7375451e66c4d Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Mon, 25 Jan 2021 08:14:49 +0100 +Subject: [PATCH 3/6] fix [-Wunused-const-variable=] + +--- + gmagick.c | 23 ----------------------- + 1 file changed, 23 deletions(-) + +diff --git a/gmagick.c b/gmagick.c +index 67256ec..158117c 100644 +--- a/gmagick.c ++++ b/gmagick.c +@@ -576,12 +576,6 @@ ZEND_BEGIN_ARG_INFO_EX(gmagick_newimage_args, 0, 0, 3) + ZEND_ARG_INFO(0, format) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(gmagick_newpseudoimage_args, 0, 0, 3) +- ZEND_ARG_INFO(0, columns) +- ZEND_ARG_INFO(0, rows) +- ZEND_ARG_INFO(0, pseudoString) +-ZEND_END_ARG_INFO() +- + ZEND_BEGIN_ARG_INFO_EX(gmagick_getresourcelimit_args, 0, 0, 1) + ZEND_ARG_INFO(0, resource_type) + ZEND_END_ARG_INFO() +@@ -595,14 +589,6 @@ ZEND_BEGIN_ARG_INFO_EX(gmagick_normalizeimage_args, 0, 0, 0) + ZEND_ARG_INFO(0, CHANNEL) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(gmagick_oilpaintimage_args, 0, 0, 1) +- ZEND_ARG_INFO(0, radius) +-ZEND_END_ARG_INFO() +- +-ZEND_BEGIN_ARG_INFO_EX(gmagick_previewimages_args, 0, 0, 1) +- ZEND_ARG_INFO(0, PREVIEW) +-ZEND_END_ARG_INFO() +- + ZEND_BEGIN_ARG_INFO_EX(gmagick_profileimage_args, 0, 0, 2) + ZEND_ARG_INFO(0, name) + ZEND_ARG_INFO(0, profile) +@@ -624,10 +610,6 @@ ZEND_BEGIN_ARG_INFO_EX(gmagick_quantizeimages_args, 0, 0, 5) + ZEND_ARG_INFO(0, measureError) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(gmagick_queryfonts_args, 0, 0, 1) +- ZEND_ARG_INFO(0, pattern) +-ZEND_END_ARG_INFO() +- + ZEND_BEGIN_ARG_INFO_EX(gmagick_queryfontmetrics_args, 0, 0, 2) + ZEND_ARG_OBJ_INFO(0, GmagickDraw, GmagickDraw, 0) + ZEND_ARG_INFO(0, text) +@@ -725,11 +707,6 @@ ZEND_BEGIN_ARG_INFO_EX(gmagick_whitethresholdimage_args, 0, 0, 1) + ZEND_ARG_INFO(0, color) + ZEND_END_ARG_INFO() + +-ZEND_BEGIN_ARG_INFO_EX(gmagick_writeimages_args, 0, 0, 2) +- ZEND_ARG_INFO(0, filename) +- ZEND_ARG_INFO(0, adjoin) +-ZEND_END_ARG_INFO() +- + ZEND_BEGIN_ARG_INFO_EX(gmagick_sampleimage_args, 0, 0, 2) + ZEND_ARG_INFO(0, columns) + ZEND_ARG_INFO(0, rows) + +From fa7ae4843818fd752466c60a8574bbe7e3a4292b Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Mon, 25 Jan 2021 12:52:58 +0100 +Subject: [PATCH 5/6] Fix error: 'i' undeclared + +--- + gmagick.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/gmagick.c b/gmagick.c +index 158117c..60bbc07 100644 +--- a/gmagick.c ++++ b/gmagick.c +@@ -1753,6 +1753,10 @@ PHP_MINIT_FUNCTION(gmagick) + */ + PHP_MSHUTDOWN_FUNCTION(gmagick) + { ++#ifndef HAVE_OMP_PAUSE_RESOURCE_ALL ++ int i; ++#endif ++ + DestroyMagick(); + #if HAVE_OMP_PAUSE_RESOURCE_ALL + // Note there is a patch to add omp_pause_resource_all to DestroyMagick() + +From 759eb6277f49c122178cea9f78cd41b349c78fff Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Mon, 25 Jan 2021 13:57:28 +0100 +Subject: [PATCH 6/6] AC_COMPILE_IFELSE instead of AC_CHECH_FUNC + +--- + config.m4 | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/config.m4 b/config.m4 +index 8bd545a..6f76fd6 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -30,7 +30,19 @@ if test $PHP_GMAGICK != "no"; then + AC_MSG_CHECKING(GraphicsMagick version mask) + AC_MSG_RESULT(found version $GRAPHICSMAGICK_VERSION_MASK) + +- PHP_CHECK_FUNC(omp_pause_resource_all, gomp) ++ ++ AC_MSG_CHECKING(omp_pause_resource_all usability) ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++ #include <omp.h> ++ ]],[[ ++ omp_pause_resource_all(omp_pause_hard); ++ ]])],[ ++ AC_MSG_RESULT(yes) ++ PHP_CHECK_FUNC(omp_pause_resource_all, gomp) ++ PHP_ADD_LIBRARY(gomp,, GMAGICK_SHARED_LIBADD) ++ ],[ ++ AC_MSG_RESULT(no) ++ ]) + + LIB_DIR=$WAND_DIR/lib + # If "$LIB_DIR" == "/usr/lib" or possible /usr/$PHP_LIBDIR" then you're probably @@ -0,0 +1,29 @@ +From f9cd4e44d4c2a669975ffa30fea180443e98af98 Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Mon, 25 Jan 2021 14:03:44 +0100 +Subject: [PATCH] gmagick.set_single_thread=1 by default + +--- + gmagick.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gmagick.c b/gmagick.c +index 67256ec..d26a996 100644 +--- a/gmagick.c ++++ b/gmagick.c +@@ -1693,13 +1693,13 @@ static zend_function_entry php_gmagickpixel_class_methods[] = + /* }}} */ + + PHP_INI_BEGIN() +- STD_PHP_INI_ENTRY("gmagick.set_single_thread", "0", PHP_INI_SYSTEM, OnUpdateBool, set_single_thread, zend_gmagick_globals, gmagick_globals) ++ STD_PHP_INI_ENTRY("gmagick.set_single_thread", "1", PHP_INI_SYSTEM, OnUpdateBool, set_single_thread, zend_gmagick_globals, gmagick_globals) + STD_PHP_INI_ENTRY("gmagick.shutdown_sleep_count", "10", PHP_INI_ALL, OnUpdateLong, shutdown_sleep_count, zend_gmagick_globals, gmagick_globals) + PHP_INI_END() + + static void php_gmagick_init_globals(zend_gmagick_globals *gmagick_globals) + { +- gmagick_globals->set_single_thread = 0; ++ gmagick_globals->set_single_thread = 1; + // 10 is magick number, that seems to be enough. + gmagick_globals->shutdown_sleep_count = 10; + } diff --git a/50.patch b/50.patch new file mode 100644 index 0000000..daf4245 --- /dev/null +++ b/50.patch @@ -0,0 +1,439 @@ +From 991ef7898acc361044c647f65072b45f91840006 Mon Sep 17 00:00:00 2001 +From: Rasmus Lerdorf <rasmus@lerdorf.com> +Date: Sat, 23 Jan 2021 22:26:29 -0800 +Subject: [PATCH 1/2] Some work on PHP 8 support Still more to do because it + crashes on many tests unless I run with OMP_NUM_THREADS=1 This doesn't seem + to be a PHP 8 problem as I see the same with PHP 7.4, but not with 7.3 + +--- + gmagick.c | 39 +++++++++++++++++++++++--- + gmagick_methods.c | 4 --- + php_gmagick.h | 51 ++++++++++++++++++++++++++++++++++ + php_gmagick_macros.h | 66 ++++++++++++++++++++++++++++++++++++++++---- + 4 files changed, 146 insertions(+), 14 deletions(-) + +diff --git a/gmagick.c b/gmagick.c +index 27ec8cc..0e9a57a 100644 +--- a/gmagick.c ++++ b/gmagick.c +@@ -85,20 +85,37 @@ static zend_object *php_gmagick_object_new(zend_class_entry *class_type) + + /* {{{ static zend_object *php_gmagick_clone_gmagick_object(zval *this_ptr TSRMLS_DC) + */ ++#if PHP_MAJOR_VERSION < 8 + static zend_object *php_gmagick_clone_gmagick_object(zval *this_ptr TSRMLS_DC) + { + php_gmagick_object *old_obj = Z_GMAGICK_OBJ_P(this_ptr); + php_gmagick_object *new_obj = GMAGICK_FETCH_OBJECT(php_gmagick_object_new_ex(old_obj->zo.ce, 0)); +- ++ + zend_objects_clone_members(&new_obj->zo, &old_obj->zo); +- ++ + if (new_obj->magick_wand) { + DestroyMagickWand(new_obj->magick_wand); + } +- ++ + new_obj->magick_wand = CloneMagickWand(old_obj->magick_wand); + return &new_obj->zo; + } ++#else ++static zend_object *php_gmagick_clone_gmagick_object(zend_object *this_ptr) ++{ ++ php_gmagick_object *old_obj = GMAGICK_FETCH_OBJECT(this_ptr); ++ php_gmagick_object *new_obj = GMAGICK_FETCH_OBJECT(php_gmagick_object_new_ex(this_ptr->ce, 0)); ++ ++ zend_objects_clone_members(&new_obj->zo, &old_obj->zo); ++ ++ if (new_obj->magick_wand) { ++ DestroyMagickWand(new_obj->magick_wand); ++ } ++ ++ new_obj->magick_wand = CloneMagickWand(old_obj->magick_wand); ++ return &new_obj->zo; ++} ++#endif + /* }}} */ + + /* {{{ static void php_gmagickdraw_object_free_storage(zend_object *object) +@@ -203,6 +220,7 @@ static zend_object *php_gmagickpixel_object_new(zend_class_entry *class_type TSR + + /* {{{ static zend_object *php_gmagick_clone_gmagickpixel_object(zval *this_ptr) + */ ++#if PHP_MAJOR_VERSION < 8 + static zend_object *php_gmagick_clone_gmagickpixel_object(zval *this_ptr) + { + php_gmagickpixel_object *old_obj = Z_GMAGICKPIXEL_OBJ_P(this_ptr); +@@ -213,6 +231,19 @@ static zend_object *php_gmagick_clone_gmagickpixel_object(zval *this_ptr) + + return &new_obj->zo; + } ++#else ++static zend_object *php_gmagick_clone_gmagickpixel_object(zend_object *this_ptr) ++{ ++ php_gmagickpixel_object *old_obj = GMAGICKPIXEL_FETCH_OBJECT(this_ptr); ++ php_gmagickpixel_object *new_obj = GMAGICKPIXEL_FETCH_OBJECT(php_gmagickpixel_object_new_ex(old_obj->zo.ce, 0)); ++ ++ zend_objects_clone_members(&new_obj->zo, &old_obj->zo); ++ GMAGICK_CLONE_PIXELWAND(old_obj->pixel_wand, new_obj->pixel_wand); ++ ++ return &new_obj->zo; ++} ++ ++#endif + /* }}} */ + + ZEND_BEGIN_ARG_INFO_EX(gmagick_empty_args, 0, 0, 0) +@@ -1020,7 +1051,7 @@ static zend_function_entry php_gmagick_class_methods[] = + PHP_ME(gmagick, setimagewhitepoint, gmagick_setimagewhitepoint_args, ZEND_ACC_PUBLIC) + PHP_ME(gmagick, setsamplingfactors, gmagick_setsamplingfactors_args, ZEND_ACC_PUBLIC) + PHP_ME(gmagick, setsize, gmagick_setsize_args, ZEND_ACC_PUBLIC) +- PHP_ME(gmagick, getversion, gmagick_empty_args, ZEND_ACC_PUBLIC) ++ PHP_ME(gmagick, getversion, gmagick_empty_args, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(gmagick, getimagegeometry, gmagick_empty_args, ZEND_ACC_PUBLIC) + PHP_ME(gmagick, getimage, gmagick_empty_args, ZEND_ACC_PUBLIC) + PHP_ME(gmagick, setimage, gmagick_setimage_args, ZEND_ACC_PUBLIC) +diff --git a/gmagick_methods.c b/gmagick_methods.c +index d2a0749..39c48a4 100644 +--- a/gmagick_methods.c ++++ b/gmagick_methods.c +@@ -3091,10 +3091,6 @@ PHP_METHOD(gmagick, getversion) + char *version_string; + unsigned long version_number; + +- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) { +- return; +- } +- + version_string = (char *)MagickGetVersion(&version_number); + array_init(return_value); + +diff --git a/php_gmagick.h b/php_gmagick.h +index 91baeda..f5e25ca 100644 +--- a/php_gmagick.h ++++ b/php_gmagick.h +@@ -57,6 +57,57 @@ typedef long ssize_t; + #include "ext/standard/info.h" + #include "ext/standard/php_filestat.h" + ++/* backward compat macros */ ++ ++#ifndef TSRMLS_CC ++#define TSRMLS_FETCH() ++#define TSRMLS_CC ++#define TSRMLS_DC ++#define TSRMLS_D ++#define TSRMLS_C ++#endif ++ ++#ifndef IS_MIXED ++# define IS_MIXED 0 ++#endif ++ ++#ifndef ZEND_ARG_INFO_WITH_DEFAULT_VALUE ++#define ZEND_ARG_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, default_value) \ ++ ZEND_ARG_INFO(pass_by_ref, name) ++#endif ++ ++#if PHP_VERSION_ID < 70200 ++#undef ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX ++#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \ ++ static const zend_internal_arg_info name[] = { \ ++ { (const char*)(zend_uintptr_t)(required_num_args), ( #class_name ), 0, return_reference, allow_null, 0 }, ++#endif ++ ++#ifndef ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX ++# define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \ ++ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) ++#endif ++ ++#ifndef ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX ++# define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, return_reference, num_args, type) \ ++ ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, num_args) ++#endif ++ ++#ifndef ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX ++# define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(name, return_reference, required_num_args, class_name, type) \ ++ ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args) ++#endif ++ ++#ifndef ZEND_ARG_TYPE_MASK ++# define ZEND_ARG_TYPE_MASK(pass_by_ref, name, type_mask, default_value) \ ++ ZEND_ARG_TYPE_INFO(pass_by_ref, name, 0, 0) ++#endif ++ ++#ifndef ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE ++# define ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, type_hint, allow_null, default_value) \ ++ ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) ++#endif ++ + #if GMAGICK_LIB_MASK >= 1003018 + #define GMAGICK_HAVE_SET_IMAGE_PAGE 1 + #endif +diff --git a/php_gmagick_macros.h b/php_gmagick_macros.h +index f0e204f..71da42f 100644 +--- a/php_gmagick_macros.h ++++ b/php_gmagick_macros.h +@@ -31,7 +31,7 @@ + + #define GMAGICKPIXEL_FETCH_OBJECT(zv_p) (php_gmagickpixel_object *)((char*)(zv_p) - XtOffsetOf(php_gmagickpixel_object, zo)) + #define Z_GMAGICKPIXEL_OBJ_P(zv) GMAGICKPIXEL_FETCH_OBJECT(Z_OBJ_P((zv))) +- ++ + /* }}} */ + + /* Define a set of macros to throw exceptions */ +@@ -232,6 +232,7 @@ + #endif + + /* {{{ GMAGICK_CLONE_PIXELWAND(source, target) */ ++#if PHP_MAJOR_VERSION < 8 + #define GMAGICK_CAST_PARAMETER_TO_COLOR(param, internp, caller) \ + switch (Z_TYPE_P(param)) { \ + case IS_STRING: \ +@@ -257,7 +258,35 @@ + default: \ + GMAGICK_THROW_EXCEPTION_WITH_MESSAGE(caller, "Invalid parameter provided", (long)caller); \ + break; \ +- } \ ++ } ++#else ++#define GMAGICK_CAST_PARAMETER_TO_COLOR(param, internp, caller) \ ++ switch (Z_TYPE_P(param)) { \ ++ case IS_STRING: \ ++ { \ ++ zval object; \ ++ PixelWand *pixel_wand = NewPixelWand(); \ ++ if (!PixelSetColor(pixel_wand, Z_STRVAL_P(param))) { \ ++ GMAGICK_THROW_GMAGICKPIXEL_EXCEPTION(pixel_wand, "Unrecognized color string"); \ ++ return; \ ++ } \ ++ object_init_ex(&object, php_gmagickpixel_sc_entry); \ ++ internp = Z_GMAGICKPIXEL_OBJ_P(&object); \ ++ GMAGICKPIXEL_REPLACE_PIXELWAND(internp, pixel_wand); \ ++ } \ ++ break; \ ++ case IS_OBJECT: \ ++ if (Z_OBJCE_P(param) == php_gmagickpixel_sc_entry) { \ ++ internp = Z_GMAGICKPIXEL_OBJ_P(param); \ ++ } else { \ ++ GMAGICK_THROW_EXCEPTION_WITH_MESSAGE(caller, "The parameter must be an instance of GmagickPixel or a string", (long)caller); \ ++ } \ ++ break; \ ++ default: \ ++ GMAGICK_THROW_EXCEPTION_WITH_MESSAGE(caller, "Invalid parameter provided", (long)caller); \ ++ break; \ ++ } ++#endif + /* }}} */ + + /* {{{ GMAGICK_CLONE_PIXELWAND(source, target) */ +@@ -316,9 +345,9 @@ + }\ + RETURN_NULL();\ + break;\ +- } \ +-/* }}} */ ++ } + ++#if PHP_MAJOR_VERSION < 7 + #define GMAGICK_CAST_PARAMETER_TO_OPACITY(param, internp, caller) \ + switch (Z_TYPE_P(param)) { \ + case IS_LONG: \ +@@ -342,8 +371,33 @@ + default: \ + GMAGICK_THROW_EXCEPTION_WITH_MESSAGE(caller, "Invalid parameter provided", (long)caller); \ + break; \ +- } \ +-/* }}} */ ++ } ++#else ++#define GMAGICK_CAST_PARAMETER_TO_OPACITY(param, internp, caller) \ ++ switch (Z_TYPE_P(param)) { \ ++ case IS_LONG: \ ++ case IS_DOUBLE: \ ++ { \ ++ zval object; \ ++ PixelWand *pixel_wand = NewPixelWand(); \ ++ PixelSetOpacity(pixel_wand, Z_DVAL_P(param)); \ ++ object_init_ex(&object, php_gmagickpixel_sc_entry); \ ++ internp = Z_GMAGICKPIXEL_OBJ_P(&object); \ ++ GMAGICKPIXEL_REPLACE_PIXELWAND(internp, pixel_wand); \ ++ } \ ++ break; \ ++ case IS_OBJECT: \ ++ if (Z_OBJCE_P(param) == php_gmagickpixel_sc_entry) { \ ++ internp = Z_GMAGICKPIXEL_OBJ_P(param); \ ++ } else { \ ++ GMAGICK_THROW_EXCEPTION_WITH_MESSAGE(caller, "The parameter must be an instance of GmagickPixel or a string", (long)caller); \ ++ } \ ++ break; \ ++ default: \ ++ GMAGICK_THROW_EXCEPTION_WITH_MESSAGE(caller, "Invalid parameter provided", (long)caller); \ ++ break; \ ++ } ++#endif + + /* {{{ GMAGICK_SAFEMODE_OPENBASEDIR_CHECK(filename) */ + #if PHP_VERSION_ID > 50399 + +From 21176bc6be8639198ab5fe4ed5925f42ead2a156 Mon Sep 17 00:00:00 2001 +From: Rasmus Lerdorf <rasmus@lerdorf.com> +Date: Sun, 24 Jan 2021 21:44:28 -0800 +Subject: [PATCH 2/2] Add set_single_thread and shutdown_sleep_count ini + settings to match the imagick extension but also add an config check for + omp_pause_resource_all() and use that if available + +--- + config.m4 | 2 ++ + gmagick.c | 38 +++++++++++++++++++++++++++++++++++++- + php_gmagick.h | 19 +++++++++++++++++++ + 3 files changed, 58 insertions(+), 1 deletion(-) + +diff --git a/config.m4 b/config.m4 +index c7d7c9f..8bd545a 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -30,6 +30,8 @@ if test $PHP_GMAGICK != "no"; then + AC_MSG_CHECKING(GraphicsMagick version mask) + AC_MSG_RESULT(found version $GRAPHICSMAGICK_VERSION_MASK) + ++ PHP_CHECK_FUNC(omp_pause_resource_all, gomp) ++ + LIB_DIR=$WAND_DIR/lib + # If "$LIB_DIR" == "/usr/lib" or possible /usr/$PHP_LIBDIR" then you're probably + # going to have a bad time. PHP m4 files seem to be hard-coded to not link properly against +diff --git a/gmagick.c b/gmagick.c +index 0e9a57a..67256ec 100644 +--- a/gmagick.c ++++ b/gmagick.c +@@ -21,6 +21,8 @@ + #include "php_gmagick_macros.h" + #include "php_gmagick_helpers.h" + ++ZEND_DECLARE_MODULE_GLOBALS(gmagick) ++ + /* handlers */ + static zend_object_handlers gmagick_object_handlers; + static zend_object_handlers gmagickdraw_object_handlers; +@@ -1690,6 +1692,18 @@ static zend_function_entry php_gmagickpixel_class_methods[] = + }; + /* }}} */ + ++PHP_INI_BEGIN() ++ STD_PHP_INI_ENTRY("gmagick.set_single_thread", "0", PHP_INI_SYSTEM, OnUpdateBool, set_single_thread, zend_gmagick_globals, gmagick_globals) ++ STD_PHP_INI_ENTRY("gmagick.shutdown_sleep_count", "10", PHP_INI_ALL, OnUpdateLong, shutdown_sleep_count, zend_gmagick_globals, gmagick_globals) ++PHP_INI_END() ++ ++static void php_gmagick_init_globals(zend_gmagick_globals *gmagick_globals) ++{ ++ gmagick_globals->set_single_thread = 0; ++ // 10 is magick number, that seems to be enough. ++ gmagick_globals->shutdown_sleep_count = 10; ++} ++ + /* {{{ PHP_MINIT_FUNCTION(gmagick) + */ + PHP_MINIT_FUNCTION(gmagick) +@@ -1698,6 +1712,8 @@ PHP_MINIT_FUNCTION(gmagick) + size_t cwd_len; + + zend_class_entry ce; ++ ++ ZEND_INIT_MODULE_GLOBALS(gmagick, php_gmagick_init_globals, NULL); + + /* Exception */ + INIT_CLASS_ENTRY(ce, "GmagickException", NULL); +@@ -1738,12 +1754,20 @@ PHP_MINIT_FUNCTION(gmagick) + + if (!cwd) + return FAILURE; +- ++ ++ + InitializeMagick(cwd); + efree(cwd); + + /* init constants */ + php_gmagick_initialize_constants(); ++ ++ REGISTER_INI_ENTRIES(); ++ ++ if (GMAGICK_G(set_single_thread)) { ++ MagickSetResourceLimit(ThreadsResource, 1); ++ } ++ + return SUCCESS; + } + /* }}} */ +@@ -1753,6 +1777,16 @@ PHP_MINIT_FUNCTION(gmagick) + PHP_MSHUTDOWN_FUNCTION(gmagick) + { + DestroyMagick(); ++#if HAVE_OMP_PAUSE_RESOURCE_ALL ++ // Note there is a patch to add omp_pause_resource_all to DestroyMagick() ++ // https://sourceforge.net/p/graphicsmagick/patches/63/ ++ // But it hasn't been accepted ++ omp_pause_resource_all(omp_pause_hard); ++#else ++ for (i = 0; i < 100 && i < GMAGICK_G(shutdown_sleep_count); i += 1) { ++ usleep(1000); ++ } ++#endif + return SUCCESS; + } + /* }}} */ +@@ -1771,6 +1805,8 @@ PHP_MINFO_FUNCTION(gmagick) + php_info_print_table_row(2, "gmagick version", PHP_GMAGICK_VERSION); + php_info_print_table_row(2, "GraphicsMagick version", version); + php_info_print_table_end(); ++ ++ DISPLAY_INI_ENTRIES(); + } + + /* {{{ zend_module_entry gmagick_module_entry +diff --git a/php_gmagick.h b/php_gmagick.h +index f5e25ca..25ddc56 100644 +--- a/php_gmagick.h ++++ b/php_gmagick.h +@@ -29,6 +29,7 @@ + /* Include GraphicsMagick header */ + #include <stdio.h> + #include <sys/types.h> ++ + #if defined(PHP_WIN32) && !defined(ssize_t) + /* XXX actually wand_api.h should be included after php.h, + ssize_t were there with much more probability. */ +@@ -57,6 +58,10 @@ typedef long ssize_t; + #include "ext/standard/info.h" + #include "ext/standard/php_filestat.h" + ++#if HAVE_OMP_PAUSE_RESOURCE_ALL ++#include <omp.h> ++#endif ++ + /* backward compat macros */ + + #ifndef TSRMLS_CC +@@ -134,6 +139,20 @@ typedef struct _php_gmagickpixel_object { + zend_object zo; + } php_gmagickpixel_object; + ++/* Globals, needed for the ini settings */ ++ZEND_BEGIN_MODULE_GLOBALS(gmagick) ++ zend_bool set_single_thread; ++ zend_long shutdown_sleep_count; ++ZEND_END_MODULE_GLOBALS(gmagick) ++ ++#ifdef ZTS ++# define GMAGICK_G(v) TSRMG(gmagick_globals_id, zend_gmagick_globals *, v) ++#else ++# define GMAGICK_G(v) (gmagick_globals.v) ++#endif ++ ++ZEND_EXTERN_MODULE_GLOBALS(gmagick) ++ + extern zend_module_entry gmagick_module_entry; + #define phpext_gmagick_ptr &gmagick_module_entry + diff --git a/gmagick-bug78465.patch b/gmagick-bug78465.patch deleted file mode 100644 index 41c27a2..0000000 --- a/gmagick-bug78465.patch +++ /dev/null @@ -1,29 +0,0 @@ -Workaround to https://bugs.php.net/78465 - - -diff -up ./gmagick.c.old ./gmagick.c ---- ./gmagick.c.old 2020-02-19 11:10:43.388127352 +0100 -+++ ./gmagick.c 2020-02-19 11:10:48.691101111 +0100 -@@ -1742,6 +1742,13 @@ PHP_MINFO_FUNCTION(gmagick) - php_info_print_table_end(); - } - -+/* {{{ PHP_MINFO_FUNCTION(gmagick) -+*/ -+PHP_RINIT_FUNCTION(gmagick) -+{ -+ MagickSetResourceLimit(ThreadsResource, 1); -+} -+ - /* {{{ zend_module_entry gmagick_module_entry - */ - zend_module_entry gmagick_module_entry = -@@ -1751,7 +1758,7 @@ zend_module_entry gmagick_module_entry = - php_gmagick_functions, /* Functions */ - PHP_MINIT(gmagick), /* MINIT */ - PHP_MSHUTDOWN(gmagick), /* MSHUTDOWN */ -- NULL, /* RINIT */ -+ PHP_RINIT(gmagick), /* RINIT */ - NULL, /* RSHUTDOWN */ - PHP_MINFO(gmagick), /* MINFO */ - PHP_GMAGICK_VERSION, /* Version */ diff --git a/php-pecl-gmagick.spec b/php-pecl-gmagick.spec index 3fb1f49..28b4ed7 100644 --- a/php-pecl-gmagick.spec +++ b/php-pecl-gmagick.spec @@ -1,6 +1,6 @@ # spec file for php-pecl-gmagick # -# Copyright (c) 2010-2020 Remi Collet +# Copyright (c) 2010-2021 Remi Collet # Copyright (c) 2009-2010 Pavel Alexeev # License: MIT # http://opensource.org/licenses/MIT @@ -23,13 +23,17 @@ Summary: Provides a wrapper to the GraphicsMagick library Name: %{?sub_prefix}php-pecl-%{pecl_name} Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}} -Release: 7%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 8%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: PHP URL: https://pecl.php.net/package/%{pecl_name} Source0: https://pecl.php.net/get/%{pecl_name}-%{upstream_version}%{?upstream_prever}.tgz -Patch0: %{pecl_name}-bug78465.patch +Source1: https://raw.githubusercontent.com/rlerdorf/gmagick/master/tests/skipif.inc +Patch0: https://patch-diff.githubusercontent.com/raw/vitoc/gmagick/pull/50.patch +Patch1: https://patch-diff.githubusercontent.com/raw/rlerdorf/gmagick/pull/1.patch +Patch2: https://patch-diff.githubusercontent.com/raw/rlerdorf/gmagick/pull/2.patch +BuildRequires: make BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-pear BuildRequires: %{?scl_prefix}php-devel >= 7.0.1 @@ -51,30 +55,17 @@ Provides: %{?scl_prefix}php-pecl-%{pecl_name}%{?_isa} = %{version}-%{rele Conflicts: %{?scl_prefix}php-pecl-imagick Conflicts: %{?scl_prefix}php-magickwand -%if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} +%if "%{?packager}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} # Other third party repo stuff -%if "%{php_version}" > "7.1" -Obsoletes: php71u-pecl-%{pecl_name} <= %{version} -Obsoletes: php71w-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.2" -Obsoletes: php72u-pecl-%{pecl_name} <= %{version} -Obsoletes: php72w-pecl-%{pecl_name} <= %{version} -%endif %if "%{php_version}" > "7.3" Obsoletes: php73-pecl-%{pecl_name} <= %{version} -Obsoletes: php73w-pecl-%{pecl_name} <= %{version} %endif %if "%{php_version}" > "7.4" Obsoletes: php74-pecl-%{pecl_name} <= %{version} -Obsoletes: php74w-pecl-%{pecl_name} <= %{version} %endif +%if "%{php_version}" > "8.0" +Obsoletes: php80-pecl-%{pecl_name} <= %{version} %endif - -%if 0%{?fedora} < 20 && 0%{?rhel} < 7 -# Filter private shared -%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$} -%{?filter_setup} %endif @@ -95,7 +86,10 @@ sed -e 's/role="test"/role="src"/' \ mv %{pecl_name}-%{upstream_version}%{?upstream_prever} NTS cd NTS -%patch0 -p1 -b .bug78465 +%patch0 -p1 -b .pr50 +%patch1 -p1 -b .pr1 +%patch2 -p1 -b .pr2 +cp %{SOURCE1} tests/skipif.inc extver=$(sed -n '/#define PHP_GMAGICK_VERSION/{s/.* "//;s/".*$//;p}' php_gmagick.h) if test "x${extver}" != "x%{upstream_version}%{?upstream_prever}"; then @@ -175,7 +169,9 @@ fi %check -%if 0%{?fedora} >= 27 || 0%{?rhel} >= 7 +rm ?TS/tests/gmagick-056-set_getsamplingfactors.phpt + +%if 0%{?fedora} == 31 || 0%{?rhel} == 8 # see https://bugzilla.redhat.com/1530057 rm ?TS/tests/gmagick-006-annotateimage.phpt rm ?TS/tests/gmagickdraw-003-annotate.phpt @@ -189,7 +185,7 @@ rm ?TS/tests/gmagickdraw_045_setFontFamily_basic.phpt cd NTS %{__php} --no-php-ini \ --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ - --modules | grep %{pecl_name} + --modules | grep '^%{pecl_name}$' : upstream test suite for NTS extension export TEST_PHP_EXECUTABLE=%{__php} @@ -203,7 +199,7 @@ export TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{pecl_name}.so" cd ../ZTS %{__ztsphp} --no-php-ini \ --define extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so \ - --modules | grep %{pecl_name} + --modules | grep '^%{pecl_name}$' : upstream test suite for ZTS extension export TEST_PHP_EXECUTABLE=%{__ztsphp} @@ -227,6 +223,13 @@ export TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{pecl_name}.so" %changelog +* Wed Feb 19 2020 Remi Collet <remi@remirepo.net> - 2.0.5~RC1-8 +- add patch for PHP 8 from + https://github.com/vitoc/gmagick/pull/50 +- add build fixes from + https://github.com/rlerdorf/gmagick/pull/1 + https://github.com/rlerdorf/gmagick/pull/2 + * Wed Feb 19 2020 Remi Collet <remi@remirepo.net> - 2.0.5~RC1-7 - better workaround to https://bugs.php.net/78465 diff --git a/skipif.inc b/skipif.inc new file mode 100644 index 0000000..f759ced --- /dev/null +++ b/skipif.inc @@ -0,0 +1,12 @@ +<?php + +if (!extension_loaded("gmagick")) die("skip"); + +function checkClassMethods($class, $methods) +{ + foreach ($methods as $method) { + if (method_exists($class, $method) == false) { + die("skip Class method $class::$method not present"); + } + } +} |