From 1a660831e1f3a277e2b131c04347a2e14968106a Mon Sep 17 00:00:00 2001 From: Danack Date: Tue, 24 Feb 2015 19:18:04 +0000 Subject: [PATCH] Enabled -Wall and fixed various small issues. Added test for progress monitor via callback, which is broken in 7. --- configure-cflags.sh | 2 +- imagick_class.c | 6 ++- imagick_helpers.c | 23 +++++----- imagickdraw_class.c | 7 ++- imagickkernel_class.c | 20 +++++---- php_imagick_defs.h | 1 + tests/127_Imagick_progressMonitor_basic.phpt | 46 ++++++++++++++++++++ 7 files changed, 80 insertions(+), 25 deletions(-) create mode 100644 tests/127_Imagick_progressMonitor_basic.phpt diff --git a/configure-cflags.sh b/configure-cflags.sh index d4090241..970e9bf1 100644 --- a/configure-cflags.sh +++ b/configure-cflags.sh @@ -46,7 +46,7 @@ echo "strictImageMagick is ${strictImageMagick}" echo "strictPHP is ${strictPHP}" if [[ $strictPHP = '1' ]] && [[ $strictImageMagick = '1' ]]; then - CFLAGS="-Wno-deprecated-declarations -Wdeclaration-after-statement -Werror"; + CFLAGS="-Wno-deprecated-declarations -Wdeclaration-after-statement -Werror -Wall"; else CFLAGS="-Wno-deprecated-declarations"; fi diff --git a/imagick_class.c b/imagick_class.c index 42bacc1e..894319ff 100644 --- a/imagick_class.c +++ b/imagick_class.c @@ -3416,7 +3416,6 @@ PHP_METHOD(imagick, readimages) zval *value; zval *files; php_imagick_object *intern; - HashPosition pos; php_imagick_rw_result_t rc; /* Parse parameters given to function */ @@ -11237,8 +11236,11 @@ PHP_METHOD(imagick, setprogressmonitor) callback->previous_callback = IMAGICK_G(progress_callback); //Add a ref and store the user's callback - //Z_ADDREF_P(user_callback); +#ifdef ZEND_ENGINE_3 Z_TRY_ADDREF_P(user_callback); +#else + Z_ADDREF_P(user_callback); +#endif callback->user_callback = user_callback; //The callback is now valid, store it in the global diff --git a/imagick_helpers.c b/imagick_helpers.c index 74a0cc78..b5d6ecab 100644 --- a/imagick_helpers.c +++ b/imagick_helpers.c @@ -67,11 +67,11 @@ MagickBooleanType php_imagick_progress_monitor_callable(const char *text, const { int error; zend_fcall_info fci; - zval retval; zend_fcall_info_cache fci_cache; #ifdef ZEND_ENGINE_3 zval zargs[2]; + zval retval; #else zval **zargs[2]; zval *retval_ptr; @@ -81,7 +81,9 @@ MagickBooleanType php_imagick_progress_monitor_callable(const char *text, const //IMAGICK_G(progress_callback) - this should be quicker php_imagick_callback *callback = (php_imagick_callback*)userData; +#ifndef ZEND_ENGINE_3 TSRMLS_FETCH_FROM_CTX(callback->thread_ctx); +#endif fci_cache = empty_fcall_info_cache; fci.size = sizeof(fci); @@ -233,7 +235,6 @@ zend_bool php_imagick_validate_map(const char *map TSRMLS_DC) double *php_imagick_zval_to_double_array(zval *param_array, long *num_elements TSRMLS_DC) { - zval **ppzval; double *double_array; long i = 0; @@ -241,6 +242,8 @@ double *php_imagick_zval_to_double_array(zval *param_array, long *num_elements T zend_ulong num_key; zend_string *key; zval *pzvalue; +#else + zval **ppzval; #endif *num_elements = zend_hash_num_elements(Z_ARRVAL_P(param_array)); @@ -284,7 +287,6 @@ double *php_imagick_zval_to_double_array(zval *param_array, long *num_elements T long *php_imagick_zval_to_long_array(zval *param_array, long *num_elements TSRMLS_DC) { - zval **ppzval; long *long_array; long i = 0; @@ -292,6 +294,8 @@ long *php_imagick_zval_to_long_array(zval *param_array, long *num_elements TSRML zend_ulong num_key; zend_string *key; zval *pzvalue; +#else + zval **ppzval; #endif *num_elements = zend_hash_num_elements(Z_ARRVAL_P(param_array)); @@ -305,8 +309,6 @@ long *php_imagick_zval_to_long_array(zval *param_array, long *num_elements TSRML #ifdef ZEND_ENGINE_3 ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(param_array), num_key, key, pzvalue) { - zval tmp_zval, *tmp_pzval; - long value = 0; long_array[i] = zval_get_long(pzvalue); i++; } ZEND_HASH_FOREACH_END(); @@ -339,7 +341,6 @@ long *php_imagick_zval_to_long_array(zval *param_array, long *num_elements TSRML unsigned char *php_imagick_zval_to_char_array(zval *param_array, long *num_elements TSRMLS_DC) { - zval **ppzval; unsigned char *char_array; long i = 0; @@ -347,6 +348,8 @@ unsigned char *php_imagick_zval_to_char_array(zval *param_array, long *num_eleme zend_ulong num_key; zend_string *key; zval *pzvalue; +#else + zval **ppzval; #endif *num_elements = zend_hash_num_elements(Z_ARRVAL_P(param_array)); @@ -359,9 +362,6 @@ unsigned char *php_imagick_zval_to_char_array(zval *param_array, long *num_eleme #ifdef ZEND_ENGINE_3 ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(param_array), num_key, key, pzvalue) { - zval tmp_zval, *tmp_pzval; - long value = 0; - char_array[i] = zval_get_long(pzvalue); i++; } ZEND_HASH_FOREACH_END(); @@ -493,14 +493,15 @@ PointInfo *php_imagick_zval_to_pointinfo_array(zval *coordinate_array, int *num_ { PointInfo *coordinates; long elements, sub_elements, i; - HashTable *coords; - zval **ppzval; HashTable *sub_array; #ifdef ZEND_ENGINE_3 zend_ulong num_key; zend_string *key; zval *pzvalue; +#else + HashTable *coords; + zval **ppzval; #endif i = 0; diff --git a/imagickdraw_class.c b/imagickdraw_class.c index 71e45f81..b4eb61b9 100644 --- a/imagickdraw_class.c +++ b/imagickdraw_class.c @@ -1187,10 +1187,13 @@ PHP_METHOD(imagickdraw, clone) PHP_METHOD(imagickdraw, affine) { php_imagickdraw_object *internd; - zval *affine_matrix, **ppzval; + zval *affine_matrix; + +#ifdef ZEND_ENGINE_3 zval *pzval; -#ifndef ZEND_ENGINE_3 +#else HashTable *affine; + zval **ppzval; #endif char *matrix_elements[] = { "sx", "rx", "ry", "sy", "tx", "ty" }; diff --git a/imagickkernel_class.c b/imagickkernel_class.c index 56846639..36ade4c8 100644 --- a/imagickkernel_class.c +++ b/imagickkernel_class.c @@ -82,24 +82,31 @@ HashTable* php_imagickkernel_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) / php_imagickkernel_object *internp; HashTable *debug_info; KernelInfo *kernel_info; - zval zrv; +#ifdef ZEND_ENGINE_3 + zval matrix; +#else zval *matrix; +#endif *is_temp = 1; //var_dump will destroy the hashtable - internp = (php_imagickkernel_object *)zend_object_store_get_object(obj TSRMLS_CC); + internp = Z_IMAGICKKERNEL_P(obj); kernel_info = internp->kernel_info; ALLOC_HASHTABLE(debug_info); ZEND_INIT_SYMTABLE_EX(debug_info, 1, 0); - INIT_PZVAL(&zrv); - while (kernel_info != NULL) { +#ifdef ZEND_ENGINE_3 + array_init(&matrix); + php_imagickkernelvalues_to_zval(&matrix, kernel_info); + zend_hash_next_index_insert(debug_info, &matrix); +#else MAKE_STD_ZVAL(matrix); array_init(matrix); php_imagickkernelvalues_to_zval(matrix, kernel_info); zend_hash_next_index_insert(debug_info, &matrix, sizeof(zval *), NULL); +#endif kernel_info = kernel_info->next; } @@ -189,8 +196,6 @@ static void createKernelZval(zval *pzval, KernelInfo *kernel_info TSRMLS_DC) { #ifdef ZEND_ENGINE_3 PHP_METHOD(imagickkernel, frommatrix) { - php_imagickkernel_object *internp; - php_imagickkernel_object *intern_return; zval *kernel_array; zval *origin_array; HashTable *inner_array; @@ -228,15 +233,12 @@ PHP_METHOD(imagickkernel, frommatrix) for (row=0 ; row +--FILE-- + 20) { + $status = "Processing cancelled"; + return false; + } + + $nowTime = time(); + + if ($nowTime - $startTime > 5) { + $status = "Processing cancelled"; + return false; + } + + return true; +}; + +$imagick = new \Imagick(); +$imagick->newPseudoImage(640, 480, "magick:logo"); + +$imagick->setProgressMonitor($callback); + +try { + + $imagick->charcoalImage($radius, $sigma); + $bytes = $imagick->getImageBlob(); + echo "Progress monitor failed to interrupt."; +} +catch(\Exception $e) { + echo $status.PHP_EOL; +} +?> +--EXPECTF-- +Processing cancelled \ No newline at end of file