1
0
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:
Niels Dossche
2025-04-26 14:27:15 +02:00
2 changed files with 24 additions and 8 deletions

View File

@@ -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;
}

View 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)