Skip to content

Commit 5b8db66

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-18431: Registering ZIP progress callback twice doesn't work
2 parents 7a2bef0 + b066ac0 commit 5b8db66

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ PHP NEWS
1515
. Fixed bug GH-17403 (Potential deadlock when putenv fails). (nielsdos)
1616
. Fixed bug GH-18400 (http_build_query type error is inaccurate). (nielsdos)
1717

18+
- Zip:
19+
. Fixed bug GH-18431 (Registering ZIP progress callback twice doesn't work).
20+
(nielsdos)
21+
1822
24 Apr 2025, PHP 8.4.7
1923

2024
- Core:

ext/zip/php_zip.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3054,14 +3054,11 @@ PHP_METHOD(ZipArchive, registerProgressCallback)
30543054

30553055
obj = Z_ZIP_P(self);
30563056

3057-
/* free if called twice */
3058-
_php_zip_progress_callback_free(obj);
3059-
30603057
/* register */
3061-
ZVAL_COPY(&obj->progress_callback, &fci.function_name);
30623058
if (zip_register_progress_callback_with_state(intern, rate, _php_zip_progress_callback, _php_zip_progress_callback_free, obj)) {
30633059
RETURN_FALSE;
30643060
}
3061+
ZVAL_COPY(&obj->progress_callback, &fci.function_name);
30653062

30663063
RETURN_TRUE;
30673064
}
@@ -3099,14 +3096,11 @@ PHP_METHOD(ZipArchive, registerCancelCallback)
30993096

31003097
obj = Z_ZIP_P(self);
31013098

3102-
/* free if called twice */
3103-
_php_zip_cancel_callback_free(obj);
3104-
31053099
/* register */
3106-
ZVAL_COPY(&obj->cancel_callback, &fci.function_name);
31073100
if (zip_register_cancel_callback_with_state(intern, _php_zip_cancel_callback, _php_zip_cancel_callback_free, obj)) {
31083101
RETURN_FALSE;
31093102
}
3103+
ZVAL_COPY(&obj->cancel_callback, &fci.function_name);
31103104

31113105
RETURN_TRUE;
31123106
}

ext/zip/tests/gh18431.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-18431 (Registering ZIP progress callback twice doesn't work)
3+
--EXTENSIONS--
4+
zip
5+
--FILE--
6+
<?php
7+
$file = __DIR__ . '/gh18431.zip';
8+
$callback = var_dump(...);
9+
$zip = new ZipArchive;
10+
$zip->open($file, ZIPARCHIVE::CREATE);
11+
$zip->registerProgressCallback(0.5, $callback);
12+
$zip->registerProgressCallback(0.5, $callback);
13+
$zip->addFromString('foo', 'entry #1');
14+
?>
15+
--CLEAN--
16+
<?php
17+
$file = __DIR__ . '/gh18431.zip';
18+
@unlink($file);
19+
?>
20+
--EXPECT--
21+
float(0)
22+
float(1)

0 commit comments

Comments
 (0)