From 7b2749af57dfafdaa6f41f8174075ee6f2d4c155 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Tue, 24 Feb 2026 22:11:42 +0100 Subject: [PATCH 01/12] Add GitHub workflow and PIE Configuration --- .github/workflows/ci.yml | 12 ++++++++++++ composer.json | 7 +++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..7092fa0a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,12 @@ +name: CI +on: + pull_request: null + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - run: yarn install + - run: yarn lint + - run: yarn test diff --git a/composer.json b/composer.json index 30795efb..af395a37 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "rar", - "type": "extension", + "name": "php-win-ext/rar", + "type": "php-ext", "license": [ "PHP License" ], @@ -14,5 +14,8 @@ "email": "tony@daylessday.org" } ], + "require": { + "php": ">= 8.0.0" + }, "description": "rar extension" } \ No newline at end of file From 19b94313c2b81dfe64543bb70d484e2b023433b5 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Tue, 24 Feb 2026 22:17:33 +0100 Subject: [PATCH 02/12] update code for PHP 8.2+ --- .github/workflows/ci.yml | 24 ++++++++++++++---- .github/workflows/windows.yml | 47 +++++++++++++++++++++++++++++++++++ config.w32 | 2 +- php_rar.h | 2 +- rar_error.c | 2 +- rararch.c | 9 ++++++- rarentry.c | 9 ++++++- tests/002.phpt | 2 +- tests/003.phpt | 2 +- tests/008.phpt | 2 +- 10 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7092fa0a..b811df22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,26 @@ name: CI on: - pull_request: null - + push: + branches: ['*'] jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + php-rel: ['8.2', '8.3', '8.4', '8.5'] + ts-state: [ts, nts] + steps: - uses: actions/checkout@v5 - - run: yarn install - - run: yarn lint - - run: yarn test + - name: Setup PHP + id: setup-php + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php-rel }}' + phpts: '${{ matrix.ts-state }}' + + - name: build extension + run: phpize && ./configure --enable-rar && make + - name: run tests + run: rm run-tests.php && cp run-tests8.php run-tests.php && make test \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..51b9cda3 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,47 @@ +name: Publish Windows Releases +on: + release: + types: [created] + +permissions: + contents: write + +jobs: + get-extension-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.extension-matrix.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v5 + - name: Get the extension matrix + id: extension-matrix + uses: php/php-windows-builder/extension-matrix@v1 + build: + needs: get-extension-matrix + runs-on: ${{ matrix.os }} + continue-on-error: false + strategy: + fail-fast: true + matrix: ${{fromJson(needs.get-extension-matrix.outputs.matrix)}} + steps: + - name: Checkout + uses: actions/checkout@v5 + - name: Build the extension + uses: php/php-windows-builder/extension@v1 + with: + php-version: ${{ matrix.php-version }} + arch: ${{ matrix.arch }} + ts: ${{ matrix.ts }} + args: '--enable-rar' + test-runner: 'run-tests8.php' + release: + runs-on: ubuntu-latest + needs: build + if: ${{ github.event_name == 'release' }} + steps: + - name: Upload artifact to the release + uses: php/php-windows-builder/release@v1 + with: + release: ${{ github.event.release.tag_name }} +# token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/config.w32 b/config.w32 index b72a7c09..a61ec2a8 100644 --- a/config.w32 +++ b/config.w32 @@ -31,7 +31,7 @@ if (PHP_RAR != "no") { arcread.cpp filefn.cpp \ global.cpp list.cpp \ encname.cpp file.cpp \ - secpassword.cpp options.cpp", "rar"); + secpassword.cpp options.cpp", "rar", "unrar_obj"); AC_DEFINE("HAVE_RAR", 1, "Rar support"); } diff --git a/php_rar.h b/php_rar.h index 9bdee067..3c0c4ce5 100644 --- a/php_rar.h +++ b/php_rar.h @@ -51,7 +51,7 @@ extern zend_module_entry rar_module_entry; #define phpext_rar_ptr &rar_module_entry -#define PHP_RAR_VERSION "4.2.0" +#define PHP_RAR_VERSION "4.2.1" #ifdef PHP_WIN32 #define PHP_RAR_API __declspec(dllexport) diff --git a/rar_error.c b/rar_error.c index 13a742bc..f9085ef7 100644 --- a/rar_error.c +++ b/rar_error.c @@ -247,7 +247,7 @@ void minit_rarerror(TSRMLS_D) /* {{{ */ zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC); #else rarexception_ce_ptr = zend_register_internal_class_ex(&ce, - zend_exception_get_default(TSRMLS_C)); + zend_ce_exception); #endif rarexception_ce_ptr->ce_flags |= ZEND_ACC_FINAL; zend_declare_property_bool(rarexception_ce_ptr, "usingExceptions", diff --git a/rararch.c b/rararch.c index 7cbfa26e..9cad0932 100644 --- a/rararch.c +++ b/rararch.c @@ -970,6 +970,13 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_rararchive_void, 0) ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rararchive_tostring, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() +#else +#define arginfo_rararchive_tostring arginfo_rararchive_void +#endif /* }}} */ static zend_function_entry php_rararch_class_functions[] = { @@ -984,7 +991,7 @@ static zend_function_entry php_rararch_class_functions[] = { PHP_ME_MAPPING(isBroken, rar_broken_is, arginfo_rararchive_void, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(setAllowBroken, rar_allow_broken_set, arginfo_rararchive_setallowbroken, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(close, rar_close, arginfo_rararchive_void, ZEND_ACC_PUBLIC) - PHP_ME(rararch, __toString, arginfo_rararchive_void, ZEND_ACC_PUBLIC) + PHP_ME(rararch, __toString, arginfo_rararchive_tostring, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(__construct, rar_bogus_ctor, arginfo_rararchive_void, ZEND_ACC_PRIVATE | ZEND_ACC_CTOR) #if PHP_MAJOR_VERSION >= 8 PHP_ME(rararch, getIterator, arginfo_rararchive_getiterator, ZEND_ACC_PUBLIC) diff --git a/rarentry.c b/rarentry.c index 5e680f61..cb5bdaa3 100644 --- a/rarentry.c +++ b/rarentry.c @@ -735,6 +735,13 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_rar_void, 0) ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 80200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rar_tostring, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() +#else +#define arginfo_rar_tostring arginfo_rar_void +#endif /* }}} */ static zend_function_entry php_rar_class_functions[] = { @@ -755,7 +762,7 @@ static zend_function_entry php_rar_class_functions[] = { PHP_ME(rarentry, getRedirType, arginfo_rar_void, ZEND_ACC_PUBLIC) PHP_ME(rarentry, isRedirectToDirectory, arginfo_rar_void, ZEND_ACC_PUBLIC) PHP_ME(rarentry, getRedirTarget, arginfo_rar_void, ZEND_ACC_PUBLIC) - PHP_ME(rarentry, __toString, arginfo_rar_void, ZEND_ACC_PUBLIC) + PHP_ME(rarentry, __toString, arginfo_rar_tostring, ZEND_ACC_PUBLIC) PHP_ME_MAPPING(__construct, rar_bogus_ctor, arginfo_rar_void, ZEND_ACC_PRIVATE | ZEND_ACC_CTOR) {NULL, NULL, NULL} }; diff --git a/tests/002.phpt b/tests/002.phpt index 5c00904a..b4970a72 100644 --- a/tests/002.phpt +++ b/tests/002.phpt @@ -163,5 +163,5 @@ 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, boo%s given in %s on line %d +Warning: rar_list() expects parameter 1 to be RarArchive, %s given in %s on line %d Done diff --git a/tests/003.phpt b/tests/003.phpt index 6d614a36..89c871a2 100644 --- a/tests/003.phpt +++ b/tests/003.phpt @@ -91,5 +91,5 @@ 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, boo%s given in %s on line %d +Warning: rar_entry_get() expects parameter 1 to be RarArchive, %s given in %s on line %d Done diff --git a/tests/008.phpt b/tests/008.phpt index 1287f109..1b6c75cc 100644 --- a/tests/008.phpt +++ b/tests/008.phpt @@ -31,6 +31,6 @@ 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, boo%s given in %s on line %d +Warning: rar_entry_get() expects parameter 1 to be RarArchive, %s given in %s on line %d Done From 234a78c2f79fbf9247842cd163ad6bf7050011ce Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Tue, 24 Feb 2026 23:15:05 +0100 Subject: [PATCH 03/12] :green_heart: fix CI for PHP 8.5 --- tests/038.phpt | 3 +++ tests/086.phpt | 3 +++ tests/087.phpt | 3 +++ tests/088.phpt | 3 +++ tests/089.phpt | 3 +++ tests/093.phpt | 3 +++ 6 files changed, 18 insertions(+) diff --git a/tests/038.phpt b/tests/038.phpt index 7f06547f..bcc6b5bf 100644 --- a/tests/038.phpt +++ b/tests/038.phpt @@ -4,6 +4,9 @@ RarArchive get iterator on closed file --FILE-- =80500){ + ini_set('fatal_error_backtraces', 'Off'); +} $rarF = RarArchive::open(dirname(__FILE__) . '/latest_winrar.rar'); $rarF->close(); foreach ($rarF as $k => $rarE) { diff --git a/tests/086.phpt b/tests/086.phpt index 0c3b03b3..58f19d0e 100644 --- a/tests/086.phpt +++ b/tests/086.phpt @@ -7,6 +7,9 @@ if (key_exists('USE_ZEND_ALLOC', $_ENV) && PHP_VERSION_ID < 70000) die('skip do ?> --FILE-- =80500){ + ini_set('fatal_error_backtraces', 'Off'); +} $f1 = dirname(__FILE__) . "/latest_winrar.rar"; $a = RarArchive::open($f1); diff --git a/tests/087.phpt b/tests/087.phpt index 3b2c48f8..fedc024e 100644 --- a/tests/087.phpt +++ b/tests/087.phpt @@ -4,6 +4,9 @@ RarArchive read_property gives a fatal error on a write context --FILE-- =80500){ + ini_set('fatal_error_backtraces', 'Off'); +} $f1 = dirname(__FILE__) . "/latest_winrar.rar"; $a = RarArchive::open($f1); diff --git a/tests/088.phpt b/tests/088.phpt index b637e09e..4d626638 100644 --- a/tests/088.phpt +++ b/tests/088.phpt @@ -7,6 +7,9 @@ if (key_exists('USE_ZEND_ALLOC', $_ENV) && PHP_VERSION_ID < 70000) die('skip do ?> --FILE-- =80500){ + ini_set('fatal_error_backtraces', 'Off'); +} $f1 = dirname(__FILE__) . "/latest_winrar.rar"; $a = RarArchive::open($f1); diff --git a/tests/089.phpt b/tests/089.phpt index 3f576153..6fcb8686 100644 --- a/tests/089.phpt +++ b/tests/089.phpt @@ -4,6 +4,9 @@ RarArchive unset_property gives a fatal error --FILE-- =80500){ + ini_set('fatal_error_backtraces', 'Off'); +} $f1 = dirname(__FILE__) . "/latest_winrar.rar"; $a = RarArchive::open($f1); diff --git a/tests/093.phpt b/tests/093.phpt index e3b5da2c..93fb095e 100644 --- a/tests/093.phpt +++ b/tests/093.phpt @@ -4,6 +4,9 @@ Traversal of RarArchive with foreach by reference gives error --FILE-- =80500){ + ini_set('fatal_error_backtraces', 'Off'); +} $f1 = dirname(__FILE__) . "/latest_winrar.rar"; $a = RarArchive::open($f1); From 5a930a03aaa808b047cbfe36585c6316e7abb36c Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Tue, 24 Feb 2026 23:18:14 +0100 Subject: [PATCH 04/12] :green_heart: fix CI PHP TS value --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b811df22..28fb0c3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: '${{ matrix.php-rel }}' + env: phpts: '${{ matrix.ts-state }}' - name: build extension From 52f8a3434265c8e09efb592f36417f0f11b7cfb4 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Tue, 24 Feb 2026 23:20:57 +0100 Subject: [PATCH 05/12] :wrench: update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 86886db5..aea24407 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /modules /missing /.deps +*.dep /.libs /Makefile /Makefile.fragments From 55d30dfa5df52d5b4cda18af20be62d6fa5ee7a6 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Tue, 24 Feb 2026 23:23:26 +0100 Subject: [PATCH 06/12] enable window CI for branches --- .github/workflows/ci.yml | 4 ++-- .github/workflows/windows.yml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28fb0c3f..6764d65d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ on: push: branches: ['*'] jobs: - build: + test-linux: runs-on: ubuntu-latest strategy: fail-fast: true @@ -24,4 +24,4 @@ jobs: - name: build extension run: phpize && ./configure --enable-rar && make - name: run tests - run: rm run-tests.php && cp run-tests8.php run-tests.php && make test \ No newline at end of file + run: rm run-tests.php && cp run-tests8.php run-tests.php && make test diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 51b9cda3..51025494 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -2,6 +2,8 @@ name: Publish Windows Releases on: release: types: [created] + push: + branches: ['*'] permissions: contents: write From d1c7fcd5a1728a5a9b05cd64b3b83516bb24bd0b Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Tue, 24 Feb 2026 23:33:42 +0100 Subject: [PATCH 07/12] :construction_worker: fix test for Windows --- run-tests8.php | 4 ++-- tests/101.phpt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/run-tests8.php b/run-tests8.php index 062dabb4..ef11707e 100644 --- a/run-tests8.php +++ b/run-tests8.php @@ -2829,10 +2829,10 @@ function run_test($php, $file, array $env) gdb --args {$cmd} ;; "valgrind") - USE_ZEND_ALLOC=0 valgrind $2 ${cmd} + USE_ZEND_ALLOC=0 valgrind $2 {$cmd} ;; "rr") - rr record $2 ${cmd} + rr record $2 {$cmd} ;; *) {$cmd} diff --git a/tests/101.phpt b/tests/101.phpt index 4d372b6c..ebbf01c7 100644 --- a/tests/101.phpt +++ b/tests/101.phpt @@ -3,6 +3,7 @@ Supports version 5 RAR files --SKIPIF-- Date: Tue, 24 Feb 2026 23:35:48 +0100 Subject: [PATCH 08/12] :construction_worker: fix Windows test 041 fail --- rarentry.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rarentry.c b/rarentry.c index cb5bdaa3..d5f6e7cd 100644 --- a/rarentry.c +++ b/rarentry.c @@ -65,7 +65,11 @@ void _rar_entry_to_zval(zval *parent, char *filename; int filename_size, filename_len; +#if PHP_MAJOR_VERSION >= 7 + zend_long unp_size; /* zval stores PHP ints as zend_long, so use that here */ +#else long unp_size; /* zval stores PHP ints as long, so use that here */ +#endif zval *parent_copy = parent; #if PHP_MAJOR_VERSION < 7 /* allocate zval on the heap */ @@ -85,7 +89,9 @@ void _rar_entry_to_zval(zval *parent, zend_update_property(rar_class_entry_ptr, obj, "rarfile", sizeof("rararch") - 1, parent_copy TSRMLS_CC); -#if ULONG_MAX > 0xffffffffUL +#if PHP_MAJOR_VERSION >= 7 && ZEND_ENABLE_ZVAL_LONG64 + unp_size = ((zend_long) entry->UnpSize) + (((zend_long) entry->UnpSizeHigh) << 32); +#elif PHP_MAJOR_VERSION < 7 && ULONG_MAX > 0xffffffffUL unp_size = ((long) entry->UnpSize) + (((long) entry->UnpSizeHigh) << 32); #else /* for 32-bit long, at least don't give negative values */ From 717d75ec8e2d833d8aca092d47603911d1a389b1 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Tue, 24 Feb 2026 23:48:25 +0100 Subject: [PATCH 09/12] add dump in test for debug test on windows --- tests/092.phpt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/092.phpt b/tests/092.phpt index 457bd92d..d11c09e2 100644 --- a/tests/092.phpt +++ b/tests/092.phpt @@ -27,6 +27,7 @@ echo "\n* broken file; do not allow broken (explicit)\n"; $a = RarArchive::open($b, null, 'retnull'); $a->setAllowBroken(false); var_dump($a->getEntries()); +if(PHP_OS_FAMILY==='Windows') var_dump($a); var_dump(count($a)); echo "\n* broken file; allow broken\n"; From 7ba9c28e15f7da8c07168312ae698d8c0c47ee2d Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 25 Feb 2026 00:05:22 +0100 Subject: [PATCH 10/12] try fix test 092 on Windows --- rararch.c | 9 +++++---- tests/092.phpt | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rararch.c b/rararch.c index 9cad0932..8a5ca6cf 100644 --- a/rararch.c +++ b/rararch.c @@ -544,7 +544,8 @@ static int rararch_dimensions_preamble(rar_file_t *rar, /* }}} */ /* {{{ RarArchive count_elements handler */ -static int rararch_count_elements(handler_this_t *object, long *count TSRMLS_DC) + +static int rararch_count_elements(zend_object *object, zend_long *count TSRMLS_DC) { rar_file_t *rar = NULL; size_t entry_count; @@ -555,10 +556,10 @@ static int rararch_count_elements(handler_this_t *object, long *count TSRMLS_DC) } entry_count = _rar_entry_count(rar); - if (entry_count > LONG_MAX) - entry_count = (size_t) LONG_MAX; + if (entry_count > ZEND_LONG_MAX) + entry_count = ZEND_LONG_MAX; - *count = (long) entry_count; + *count = (zend_long) entry_count; return SUCCESS; } diff --git a/tests/092.phpt b/tests/092.phpt index d11c09e2..457bd92d 100644 --- a/tests/092.phpt +++ b/tests/092.phpt @@ -27,7 +27,6 @@ echo "\n* broken file; do not allow broken (explicit)\n"; $a = RarArchive::open($b, null, 'retnull'); $a->setAllowBroken(false); var_dump($a->getEntries()); -if(PHP_OS_FAMILY==='Windows') var_dump($a); var_dump(count($a)); echo "\n* broken file; allow broken\n"; From 3f507ce2dbb489b541750bbdc92cc499538949e8 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 25 Feb 2026 00:18:51 +0100 Subject: [PATCH 11/12] update test for Windows x86 platform --- .github/workflows/windows.yml | 2 ++ tests/011.phpt | 6 +----- tests/019.phpt | 6 +----- tests/020.phpt | 6 +----- tests/046.phpt | 6 +----- tests/047.phpt | 6 +----- tests/055.phpt | 6 +----- 7 files changed, 8 insertions(+), 30 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 51025494..ca57e9e4 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -19,6 +19,8 @@ jobs: - name: Get the extension matrix id: extension-matrix uses: php/php-windows-builder/extension-matrix@v1 + with: + php-version-list: '8.1' build: needs: get-extension-matrix runs-on: ${{ matrix.os }} diff --git a/tests/011.phpt b/tests/011.phpt index d8ea9130..aea2512c 100644 --- a/tests/011.phpt +++ b/tests/011.phpt @@ -9,10 +9,6 @@ $rar_file1 = rar_open(dirname(__FILE__).'/multi.part1.rar'); $entries = rar_list($rar_file1); echo count($entries)." files:\n\n"; //var_dump($entries); -function int32_to_hex($value) { - $value &= 0xffffffff; - return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT); -} foreach ($entries as $e) { $stream = $e->getStream(); if ($stream === false) { @@ -25,7 +21,7 @@ foreach ($entries as $e) { $a .= fread($stream, 8192); } echo strlen($a)." bytes, CRC "; - echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc() + echo strtoupper(hash("crc32b", $a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc() } echo "Done\n"; diff --git a/tests/019.phpt b/tests/019.phpt index c0c73230..b6b8cb6e 100644 --- a/tests/019.phpt +++ b/tests/019.phpt @@ -9,10 +9,6 @@ $rar_file1 = rar_open(dirname(__FILE__).'/store_method.rar'); $entries = rar_list($rar_file1); echo count($entries)." files:\n\n"; //var_dump($entries); -function int32_to_hex($value) { - $value &= 0xffffffff; - return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT); -} foreach ($entries as $e) { $stream = $e->getStream(); echo $e->getName().": "; @@ -21,7 +17,7 @@ foreach ($entries as $e) { $a .= fread($stream, 512); } echo strlen($a)." bytes, CRC "; - echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc() + echo strtoupper(hash("crc32b", $a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc() } echo "Done\n"; diff --git a/tests/020.phpt b/tests/020.phpt index 111f6677..37df3f0d 100644 --- a/tests/020.phpt +++ b/tests/020.phpt @@ -9,10 +9,6 @@ $rar_file1 = rar_open(dirname(__FILE__).'/solid.rar'); $entries = rar_list($rar_file1); echo count($entries)." files:\n\n"; //var_dump($entries); -function int32_to_hex($value) { - $value &= 0xffffffff; - return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT); -} foreach ($entries as $e) { $stream = $e->getStream(); echo $e->getName().": "; @@ -21,7 +17,7 @@ foreach ($entries as $e) { $a .= fread($stream, 8192); } echo strlen($a)." bytes, CRC "; - echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc() + echo strtoupper(hash("crc32b", $a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc() } echo "Done\n"; diff --git a/tests/046.phpt b/tests/046.phpt index c93b64c0..7f4c19d8 100644 --- a/tests/046.phpt +++ b/tests/046.phpt @@ -10,10 +10,6 @@ function resolve($vol) { else return null; } -function int32_to_hex($value) { - $value &= 0xffffffff; - return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT); -} $rar_file1 = rar_open(dirname(__FILE__).'/multi_broken.part1.rar', null, 'resolve'); foreach ($rar_file1 as $e) { $stream = $e->getStream(); @@ -23,7 +19,7 @@ foreach ($rar_file1 as $e) { $a .= fread($stream, 8192); } echo strlen($a)." bytes, CRC "; - echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc() + echo strtoupper(hash("crc32b", $a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc() } echo "Done\n"; diff --git a/tests/047.phpt b/tests/047.phpt index 8bd3e90f..e0a5c248 100644 --- a/tests/047.phpt +++ b/tests/047.phpt @@ -10,10 +10,6 @@ function resolve($vol) { else return null; } -function int32_to_hex($value) { - $value &= 0xffffffff; - return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT); -} echo "Fail:\n"; $rar_file1 = rar_open(dirname(__FILE__).'/multi_broken.part1.rar'); $entry = $rar_file1->getEntry('file2.txt'); @@ -22,7 +18,7 @@ echo "\nSuccess:\n"; $rar_file1 = rar_open(dirname(__FILE__).'/multi_broken.part1.rar', null, 'resolve'); $entry = $rar_file1->getEntry('file2.txt'); $entry->extract(null, dirname(__FILE__) . "/temp_file2.txt"); -echo int32_to_hex(crc32(file_get_contents(dirname(__FILE__) . "/temp_file2.txt"))); +echo strtoupper(hash("crc32b", file_get_contents(dirname(__FILE__) . "/temp_file2.txt"))); echo "\n"; echo "Done\n"; ?> diff --git a/tests/055.phpt b/tests/055.phpt index 73d36f0d..2d981d9c 100644 --- a/tests/055.phpt +++ b/tests/055.phpt @@ -11,17 +11,13 @@ function resolve($vol) { else return null; } -function int32_to_hex($value) { - $value &= 0xffffffff; - return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT); -} $stream = fopen("rar://" . dirname(__FILE__) . '/multi_broken.part1.rar' . "#file2.txt", "r", false, stream_context_create(array('rar'=>array('volume_callback'=>'resolve')))); $a = stream_get_contents($stream); echo strlen($a)." bytes, CRC "; -echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc() +echo strtoupper(hash("crc32b", $a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc() echo "Done.\n"; --EXPECTF-- 17704 bytes, CRC F2C79881 From 792c622f3eb49ccbfd86b1ee5beec4f118041f61 Mon Sep 17 00:00:00 2001 From: macintoshplus <814683+macintoshplus@users.noreply.github.com> Date: Wed, 25 Feb 2026 00:28:11 +0100 Subject: [PATCH 12/12] remove php 8.1 limitation for Windows test --- .github/workflows/windows.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ca57e9e4..51025494 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -19,8 +19,6 @@ jobs: - name: Get the extension matrix id: extension-matrix uses: php/php-windows-builder/extension-matrix@v1 - with: - php-version-list: '8.1' build: needs: get-extension-matrix runs-on: ${{ matrix.os }}