Skip to content

Commit

Permalink
fix Imagick::count() with PHP 5.6.0RC2
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Jul 23, 2014
1 parent 9b44663 commit ca019ad
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions imagick.c
Expand Up @@ -2708,6 +2708,19 @@ static void php_imagick_init_globals(zend_imagick_globals *imagick_globals)
imagick_globals->progress_monitor = 0;
}

#if defined(HAVE_SPL)
static int php_imagick_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
{
php_imagick_object *intern= (php_imagick_object *)zend_object_store_get_object(object TSRMLS_CC);

if (intern->magick_wand) {
*count = MagickGetNumberImages(intern->magick_wand);
return SUCCESS;
}
return FAILURE;
}
#endif

#if PHP_VERSION_ID < 50399
static zval *php_imagick_read_property(zval *object, zval *member, int type TSRMLS_DC)
#else
Expand Down Expand Up @@ -2935,6 +2948,7 @@ PHP_MINIT_FUNCTION(imagick)
imagick_object_handlers.read_property = php_imagick_read_property;
php_imagick_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
#if defined(HAVE_SPL)
imagick_object_handlers.count_elements = php_imagick_count_elements;
zend_class_implements(php_imagick_sc_entry TSRMLS_CC, 2, zend_ce_iterator, spl_ce_Countable);
#else
zend_class_implements(php_imagick_sc_entry TSRMLS_CC, 1, zend_ce_iterator);
Expand Down

0 comments on commit ca019ad

Please sign in to comment.