Merge branch 'PHP-8.1' into PHP-8.2

This commit is contained in:
Tyson Andre 2023-02-03 09:18:03 -05:00
commit e3f04ddb0b
3 changed files with 38 additions and 0 deletions

2
NEWS
View file

@ -39,6 +39,8 @@ PHP NEWS
. Fixed bug GH-10292 (Made the default value of the first param of srand() and
mt_srand() unknown). (kocsismate)
. Fix incorrect check in cs_8559_5 in map_from_unicode(). (nielsdos)
. Fix bug GH-9697 for reset/end/next/prev() attempting to move pointer of
properties table for certain internal classes such as FFI classes
02 Feb 2023, PHP 8.2.2

View file

@ -0,0 +1,20 @@
--TEST--
FFI: Test deprecated use of array helper functions on FFI classes doesn't crash
--EXTENSIONS--
ffi
--INI--
ffi.enable=1
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);
$data = FFI::new('int');
var_dump(reset($data));
var_dump(end($data));
var_dump(next($data));
var_dump(prev($data));
?>
--EXPECTF--
bool(false)
bool(false)
bool(false)
bool(false)

View file

@ -1020,6 +1020,10 @@ PHP_FUNCTION(end)
ZEND_PARSE_PARAMETERS_END();
HashTable *array = get_ht_for_iap(array_zv, /* separate */ true);
if (zend_hash_num_elements(array) == 0) {
/* array->nInternalPointer is already 0 if the array is empty, even after removing elements */
RETURN_FALSE;
}
zend_hash_internal_pointer_end(array);
if (USED_RET()) {
@ -1047,6 +1051,10 @@ PHP_FUNCTION(prev)
ZEND_PARSE_PARAMETERS_END();
HashTable *array = get_ht_for_iap(array_zv, /* separate */ true);
if (zend_hash_num_elements(array) == 0) {
/* array->nInternalPointer is already 0 if the array is empty, even after removing elements */
RETURN_FALSE;
}
zend_hash_move_backwards(array);
if (USED_RET()) {
@ -1074,6 +1082,10 @@ PHP_FUNCTION(next)
ZEND_PARSE_PARAMETERS_END();
HashTable *array = get_ht_for_iap(array_zv, /* separate */ true);
if (zend_hash_num_elements(array) == 0) {
/* array->nInternalPointer is already 0 if the array is empty, even after removing elements */
RETURN_FALSE;
}
zend_hash_move_forward(array);
if (USED_RET()) {
@ -1101,6 +1113,10 @@ PHP_FUNCTION(reset)
ZEND_PARSE_PARAMETERS_END();
HashTable *array = get_ht_for_iap(array_zv, /* separate */ true);
if (zend_hash_num_elements(array) == 0) {
/* array->nInternalPointer is already 0 if the array is empty, even after removing elements */
RETURN_FALSE;
}
zend_hash_internal_pointer_reset(array);
if (USED_RET()) {