From 1225c9240e0e368dad6ccc5f618e000560b4925d Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 26 Jun 2018 15:22:42 +0200 Subject: [PATCH 1/3] relax tests for 7.3 (bool/boolean, main/count) --- tests/002.phpt | 2 +- tests/003.phpt | 2 +- tests/008.phpt | 2 +- tests/079.phpt | 4 ++-- tests/092.phpt | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/002.phpt b/tests/002.phpt index f90617a..358aba8 100644 --- a/tests/002.phpt +++ b/tests/002.phpt @@ -163,6 +163,6 @@ array(2) { Warning: rar_open(): Failed to open %s: ERAR_EOPEN (file open error) in %s on line %d -Warning: rar_list() expects parameter 1 to be RarArchive, boolean given in %s on line %d +Warning: rar_list() expects parameter 1 to be RarArchive, boo%s given in %s on line %d NULL Done diff --git a/tests/003.phpt b/tests/003.phpt index 2f0a6df..9b77d2f 100644 --- a/tests/003.phpt +++ b/tests/003.phpt @@ -89,6 +89,6 @@ object(RarEntry)#%d (%d) { Warning: rar_open(): Failed to open %s: ERAR_EOPEN (file open error) in %s on line %d -Warning: rar_entry_get() expects parameter 1 to be RarArchive, boolean given in %s on line %d +Warning: rar_entry_get() expects parameter 1 to be RarArchive, boo%s given in %s on line %d NULL Done diff --git a/tests/008.phpt b/tests/008.phpt index f79c97a..f864c97 100644 --- a/tests/008.phpt +++ b/tests/008.phpt @@ -28,7 +28,7 @@ bool(false) Warning: rar_open(): Failed to open %s: ERAR_EOPEN (file open error) in %s on line %d -Warning: rar_entry_get() expects parameter 1 to be RarArchive, boolean given in %s on line %d +Warning: rar_entry_get() expects parameter 1 to be RarArchive, boo%s given in %s on line %d NULL Done diff --git a/tests/079.phpt b/tests/079.phpt index f243b85..0ee005a 100644 --- a/tests/079.phpt +++ b/tests/079.phpt @@ -48,12 +48,12 @@ Count: 13 * Closed file test (1): -Warning: count(): The archive is already closed in %s on line %d +Warning: %s(): The archive is already closed in %s on line %d int(0) * Closed file test (2): -Warning: count(): The archive is already closed in %s on line %d +Warning: %s(): The archive is already closed in %s on line %d int(0) * Closed file test (3, exceptions): diff --git a/tests/092.phpt b/tests/092.phpt index 39b8331..6ddd6f2 100644 --- a/tests/092.phpt +++ b/tests/092.phpt @@ -54,7 +54,7 @@ Warning: rar_allow_broken_set() expects exactly 2 parameters, 1 given in %s on l Warning: RarArchive::getEntries(): ERAR_EOPEN (file open error) in %s on line %d bool(false) -Warning: count(): ERAR_EOPEN (file open error) in %s on line %d +Warning: %s(): ERAR_EOPEN (file open error) in %s on line %d int(0) * broken file; do not allow broken (explicit) @@ -62,7 +62,7 @@ int(0) Warning: RarArchive::getEntries(): ERAR_EOPEN (file open error) in %s on line %d bool(false) -Warning: count(): ERAR_EOPEN (file open error) in %s on line %d +Warning: %s(): ERAR_EOPEN (file open error) in %s on line %d int(0) * broken file; allow broken From 5ca8d78562769fe38c0b8d1b2bcb586f18ca6dd5 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 18 Jul 2018 11:02:14 +0200 Subject: [PATCH 2/3] fix for iterator changes in 7.3.0alpha4 --- rar_error.c | 2 +- rararch.c | 104 +++++++++++++++++++++++++++------------------------- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/rar_error.c b/rar_error.c index 447a19d..13a742b 100644 --- a/rar_error.c +++ b/rar_error.c @@ -252,7 +252,7 @@ void minit_rarerror(TSRMLS_D) /* {{{ */ rarexception_ce_ptr->ce_flags |= ZEND_ACC_FINAL; zend_declare_property_bool(rarexception_ce_ptr, "usingExceptions", sizeof("usingExceptions") -1, 0L /* FALSE */, - ZEND_ACC_PRIVATE | ZEND_ACC_STATIC TSRMLS_CC); + ZEND_ACC_STATIC TSRMLS_CC); } /* }}} */ diff --git a/rararch.c b/rararch.c index 1c065df..06ed9ca 100644 --- a/rararch.c +++ b/rararch.c @@ -932,55 +932,6 @@ static void rararch_it_move_forward(zend_object_iterator *iter TSRMLS_DC); static void rararch_it_rewind(zend_object_iterator *iter TSRMLS_DC); /* }}} */ -/* {{{ rararch_it_get_iterator */ -static zend_object_iterator *rararch_it_get_iterator(zend_class_entry *ce, - zval *object, - int by_ref TSRMLS_DC) -{ - rararch_iterator *it; - rar_file_t *rar; - int res; - - if (by_ref) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, - "An iterator cannot be used with foreach by reference"); - } - - it = emalloc(sizeof *it); - -#if PHP_MAJOR_VERSION < 7 - zval_add_ref(&object); - it->parent.data = object; - it->value = NULL; -#else - zend_iterator_init((zend_object_iterator *) it); - ZVAL_COPY(&it->parent.data, object); - ZVAL_UNDEF(&it->value); -#endif - - it->parent.funcs = ce->iterator_funcs.funcs; - it->state = NULL; - - res = _rar_get_file_resource_ex(object, &rar, 1 TSRMLS_CC); - if (res == FAILURE) - php_error_docref(NULL TSRMLS_CC, E_ERROR, - "Cannot fetch RarArchive object"); - if (rar->arch_handle == NULL) - php_error_docref(NULL TSRMLS_CC, E_ERROR, - "The archive is already closed, cannot give an iterator"); - res = _rar_list_files(rar TSRMLS_CC); - if (_rar_handle_error(res TSRMLS_CC) == FAILURE) { - /* if it failed, do not expose the possibly incomplete entry list */ - it->empty_iterator = 1; - } - else - it->empty_iterator = 0; - - _rar_entry_search_start(rar, RAR_SEARCH_TRAVERSE, &it->state TSRMLS_CC); - return (zend_object_iterator*) it; -} -/* }}} */ - /* {{{ rararch_it_invalidate_current */ static void rararch_it_invalidate_current(zend_object_iterator *iter TSRMLS_DC) { @@ -1147,6 +1098,59 @@ static zend_object_iterator_funcs rararch_it_funcs = { }; /* }}} */ +/* {{{ rararch_it_get_iterator */ +static zend_object_iterator *rararch_it_get_iterator(zend_class_entry *ce, + zval *object, + int by_ref TSRMLS_DC) +{ + rararch_iterator *it; + rar_file_t *rar; + int res; + + if (by_ref) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, + "An iterator cannot be used with foreach by reference"); + } + + it = emalloc(sizeof *it); + +#if PHP_MAJOR_VERSION < 7 + zval_add_ref(&object); + it->parent.data = object; + it->value = NULL; +#else + zend_iterator_init((zend_object_iterator *) it); + ZVAL_COPY(&it->parent.data, object); + ZVAL_UNDEF(&it->value); +#endif + +#if PHP_VERSION_ID < 70300 + it->parent.funcs = ce->iterator_funcs.funcs; +#else + it->parent.funcs = &rararch_it_funcs; +#endif + it->state = NULL; + + res = _rar_get_file_resource_ex(object, &rar, 1 TSRMLS_CC); + if (res == FAILURE) + php_error_docref(NULL TSRMLS_CC, E_ERROR, + "Cannot fetch RarArchive object"); + if (rar->arch_handle == NULL) + php_error_docref(NULL TSRMLS_CC, E_ERROR, + "The archive is already closed, cannot give an iterator"); + res = _rar_list_files(rar TSRMLS_CC); + if (_rar_handle_error(res TSRMLS_CC) == FAILURE) { + /* if it failed, do not expose the possibly incomplete entry list */ + it->empty_iterator = 1; + } + else + it->empty_iterator = 0; + + _rar_entry_search_start(rar, RAR_SEARCH_TRAVERSE, &it->state TSRMLS_CC); + return (zend_object_iterator*) it; +} +/* }}} */ + void minit_rararch(TSRMLS_D) { zend_class_entry ce; @@ -1170,7 +1174,9 @@ void minit_rararch(TSRMLS_D) rararch_ce_ptr->clone = NULL; rararch_ce_ptr->create_object = &rararch_ce_create_object; rararch_ce_ptr->get_iterator = rararch_it_get_iterator; +#if PHP_VERSION_ID < 70300 rararch_ce_ptr->iterator_funcs.funcs = &rararch_it_funcs; +#endif zend_class_implements(rararch_ce_ptr TSRMLS_CC, 1, zend_ce_traversable); } From 5a0cd32191356ec3e6bd7c29d684fc8d9fac7032 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 16 Aug 2018 14:52:03 +0200 Subject: [PATCH 3/3] new constant names in 7.3 --- rar_stream.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rar_stream.c b/rar_stream.c index ed2be60..3292148 100644 --- a/rar_stream.c +++ b/rar_stream.c @@ -293,7 +293,7 @@ static int _rar_stat_from_header(struct RARHeaderDataEx *header, * SUBHEAD_TYPE_UOWNER), but it is not exposed in unRAR */ ssb->sb.st_uid = 0; ssb->sb.st_gid = 0; -#ifdef HAVE_ST_RDEV +#if defined(HAVE_ST_RDEV) || defined(HAVE_STRUCT_STAT_ST_RDEV) ssb->sb.st_rdev = 0; #endif /* never mind signedness, we'll never get sizes big enough for that to @@ -324,10 +324,10 @@ static int _rar_stat_from_header(struct RARHeaderDataEx *header, &ssb->sb.st_mtime); } -#ifdef HAVE_ST_BLKSIZE +#if defined(HAVE_ST_BLKSIZE) || defined(HAVE_STRUCT_STAT_ST_BLKSIZE) ssb->sb.st_blksize = 0; #endif -#ifdef HAVE_ST_BLOCKS +#if defined(HAVE_ST_BLOCKS) || defined (HAVE_STRUCT_STAT_ST_BLOCKS) ssb->sb.st_blocks = 0; #endif /* php_stat in filestat.c doesn't check this one, so don't touch it */