@@ -566,7 +566,8 @@ vips_php_zval_to_gval(VipsImage *match_image, zval *zvalue, GValue *gvalue)
566566}
567567
568568static int
569- vips_php_set_value (VipsPhpCall * call , GParamSpec * pspec , zval * zvalue )
569+ vips_php_set_value (VipsPhpCall * call ,
570+ GParamSpec * pspec , VipsArgumentFlags flags , zval * zvalue )
570571{
571572 const char * name = g_param_spec_get_name (pspec );
572573 GType pspec_type = G_PARAM_SPEC_VALUE_TYPE (pspec );
@@ -581,7 +582,8 @@ vips_php_set_value(VipsPhpCall *call, GParamSpec *pspec, zval *zvalue)
581582 /* If we are setting a MODIFY VipsArgument with an image, we need to take a
582583 * copy.
583584 */
584- if (g_type_is_a (pspec_type , VIPS_TYPE_IMAGE )) {
585+ if (g_type_is_a (pspec_type , VIPS_TYPE_IMAGE ) &&
586+ (flags & VIPS_ARGUMENT_MODIFY )) {
585587 VipsImage * image ;
586588 VipsImage * memory ;
587589
@@ -647,7 +649,7 @@ vips_php_set_required_input(VipsObject *object,
647649 }
648650
649651 if (arg &&
650- vips_php_set_value (call , pspec , arg )) {
652+ vips_php_set_value (call , pspec , argument_class -> flags , arg )) {
651653 return call ;
652654 }
653655 }
@@ -686,7 +688,7 @@ vips_php_set_optional_input(VipsPhpCall *call, zval *options)
686688 if (!(argument_class -> flags & VIPS_ARGUMENT_REQUIRED ) &&
687689 (argument_class -> flags & VIPS_ARGUMENT_INPUT ) &&
688690 !(argument_class -> flags & VIPS_ARGUMENT_DEPRECATED ) &&
689- vips_php_set_value (call , pspec , value )) {
691+ vips_php_set_value (call , pspec , argument_class -> flags , value )) {
690692 return -1 ;
691693 }
692694 } ZEND_HASH_FOREACH_END ();
@@ -891,6 +893,12 @@ vips_php_get_optional_output(VipsPhpCall *call, zval *options,
891893 continue ;
892894 }
893895
896+ /* value should always be TRUE.
897+ */
898+ if (Z_TYPE_P (value ) != IS_TRUE ) {
899+ continue ;
900+ }
901+
894902 name = ZSTR_VAL (key );
895903 if (vips_object_get_argument (VIPS_OBJECT (call -> operation ), name ,
896904 & pspec , & argument_class , & argument_instance )) {
@@ -1046,7 +1054,6 @@ PHP_FUNCTION(vips_call)
10461054 char * operation_name ;
10471055 size_t operation_name_len ;
10481056 zval * instance ;
1049- int i ;
10501057
10511058 VIPS_DEBUG_MSG ("vips_call:\n" );
10521059
@@ -1182,7 +1189,7 @@ PHP_FUNCTION(vips_image_new_from_array)
11821189 int width ;
11831190 int height ;
11841191 VipsImage * mat ;
1185- int x , y ;
1192+ int x ;
11861193 zval * row ;
11871194
11881195 VIPS_DEBUG_MSG ("vips_image_new_from_array:\n" );
@@ -1237,6 +1244,8 @@ PHP_FUNCTION(vips_image_write_to_file)
12371244 zval * options = NULL ;
12381245 VipsImage * image ;
12391246
1247+ VIPS_DEBUG_MSG ("vips_image_write_to_file:\n" );
1248+
12401249 if (zend_parse_parameters (ZEND_NUM_ARGS (), "rp|a" ,
12411250 & IM , & filename , & filename_len , & options ) == FAILURE ) {
12421251 RETURN_LONG (-1 );
@@ -1247,6 +1256,8 @@ PHP_FUNCTION(vips_image_write_to_file)
12471256 RETURN_LONG (-1 );
12481257 }
12491258
1259+ VIPS_DEBUG_MSG ("\t%p -> %s\n" , image , filename );
1260+
12501261 if (vips_image_write_to_file (image , filename , NULL )) {
12511262 RETURN_LONG (-1 );
12521263 }
@@ -1477,7 +1488,6 @@ PHP_FUNCTION(vips_image_remove)
14771488 char * field_name ;
14781489 size_t field_name_len ;
14791490 VipsImage * image ;
1480- GType type ;
14811491
14821492 if (zend_parse_parameters (ZEND_NUM_ARGS (), "rs" ,
14831493 & im , & field_name , & field_name_len ) == FAILURE ) {
@@ -1606,6 +1616,12 @@ PHP_MINIT_FUNCTION(vips)
16061616 le_gobject = zend_register_list_destructors_ex (php_free_gobject ,
16071617 NULL , "GObject" , module_number );
16081618
1619+ #ifdef VIPS_DEBUG
1620+ printf ( "php-vips-ext init\n" );
1621+ printf ( "enabling vips leak testing ...\n" );
1622+ vips_leak_set ( TRUE );
1623+ #endif /*VIPS_DEBUG*/
1624+
16091625 return SUCCESS ;
16101626}
16111627/* }}} */
@@ -1618,6 +1634,10 @@ PHP_MSHUTDOWN_FUNCTION(vips)
16181634 UNREGISTER_INI_ENTRIES();
16191635 */
16201636
1637+ #ifdef VIPS_DEBUG
1638+ printf ( "php-vips-ext shutdown\n" );
1639+ #endif /*VIPS_DEBUG*/
1640+
16211641 vips_shutdown ();
16221642
16231643 return SUCCESS ;
0 commit comments