mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-18431: Registering ZIP progress callback twice doesn't work
This commit is contained in:
@@ -3050,14 +3050,11 @@ PHP_METHOD(ZipArchive, registerProgressCallback)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
/* free if called twice */
|
||||
php_zip_progress_callback_free(obj);
|
||||
|
||||
/* register */
|
||||
zend_fcc_dup(&obj->progress_callback, &fcc);
|
||||
if (zip_register_progress_callback_with_state(intern, rate, php_zip_progress_callback, php_zip_progress_callback_free, obj)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_fcc_dup(&obj->progress_callback, &fcc);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
@@ -3108,14 +3105,11 @@ PHP_METHOD(ZipArchive, registerCancelCallback)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
/* free if called twice */
|
||||
php_zip_cancel_callback_free(obj);
|
||||
|
||||
/* register */
|
||||
zend_fcc_dup(&obj->cancel_callback, &fcc);
|
||||
if (zip_register_cancel_callback_with_state(intern, php_zip_cancel_callback, php_zip_cancel_callback_free, obj)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
zend_fcc_dup(&obj->cancel_callback, &fcc);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
||||
22
ext/zip/tests/gh18431.phpt
Normal file
22
ext/zip/tests/gh18431.phpt
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
GH-18431 (Registering ZIP progress callback twice doesn't work)
|
||||
--EXTENSIONS--
|
||||
zip
|
||||
--FILE--
|
||||
<?php
|
||||
$file = __DIR__ . '/gh18431.zip';
|
||||
$callback = var_dump(...);
|
||||
$zip = new ZipArchive;
|
||||
$zip->open($file, ZIPARCHIVE::CREATE);
|
||||
$zip->registerProgressCallback(0.5, $callback);
|
||||
$zip->registerProgressCallback(0.5, $callback);
|
||||
$zip->addFromString('foo', 'entry #1');
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
$file = __DIR__ . '/gh18431.zip';
|
||||
@unlink($file);
|
||||
?>
|
||||
--EXPECT--
|
||||
float(0)
|
||||
float(1)
|
||||
Reference in New Issue
Block a user