From eae6b6f35edea98c64346a1538eca808ceb1e813 Mon Sep 17 00:00:00 2001 From: ColinHDev Date: Fri, 28 Apr 2023 17:12:31 +0200 Subject: [PATCH 1/7] Changed the default value of nNextFreeElement in _zend_empty_array from 0 to ZEND_LONG_MIN --- Zend/zend_hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 9c09dfdc274a..e9525db95c51 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -255,7 +255,7 @@ ZEND_API const HashTable zend_empty_array = { .nNumOfElements = 0, .nTableSize = HT_MIN_SIZE, .nInternalPointer = 0, - .nNextFreeElement = 0, + .nNextFreeElement = ZEND_LONG_MIN, .pDestructor = ZVAL_PTR_DTOR }; From fbd798b2373e34d55efda2c6044e4ca66577fae6 Mon Sep 17 00:00:00 2001 From: ColinHDev Date: Fri, 28 Apr 2023 17:13:07 +0200 Subject: [PATCH 2/7] Mentioned the change in UPGRADING file --- UPGRADING | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UPGRADING b/UPGRADING index 7920c62ccecf..689ae9ababca 100644 --- a/UPGRADING +++ b/UPGRADING @@ -39,6 +39,8 @@ PHP 8.3 UPGRADE NOTES inherited from the parent class. This will create a separate static property storage for the current class. This is analogous to adding the static property to the class directly without traits. + . Assigning a value to a negative index n in an empty array will now make sure that + the next index is n+1 and no longer default to 0. - FFI: . C functions that have a return type of void now return null instead of From 68641ed0c40fa79bf776cfca986ba82c50f10c66 Mon Sep 17 00:00:00 2001 From: ColinHDev Date: Fri, 28 Apr 2023 17:55:12 +0200 Subject: [PATCH 3/7] Added test file --- .../array/negative-index-empty-array.phpt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 ext/standard/tests/array/negative-index-empty-array.phpt diff --git a/ext/standard/tests/array/negative-index-empty-array.phpt b/ext/standard/tests/array/negative-index-empty-array.phpt new file mode 100644 index 000000000000..9f22e7a79e47 --- /dev/null +++ b/ext/standard/tests/array/negative-index-empty-array.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test empty arrays with first added index being negative +--FILE-- + +--EXPECT-- +bool(true) +array(2) { + [-5]=> + string(2) "-5" + [-4]=> + string(8) "after -5" +} \ No newline at end of file From 20970e0df233b61d71e048f98e36f412ca2328fe Mon Sep 17 00:00:00 2001 From: ColinHDev Date: Fri, 28 Apr 2023 17:58:52 +0200 Subject: [PATCH 4/7] Renamed test file --- ...ive-index-empty-array.phpt => negative_index_empty_array.phpt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ext/standard/tests/array/{negative-index-empty-array.phpt => negative_index_empty_array.phpt} (100%) diff --git a/ext/standard/tests/array/negative-index-empty-array.phpt b/ext/standard/tests/array/negative_index_empty_array.phpt similarity index 100% rename from ext/standard/tests/array/negative-index-empty-array.phpt rename to ext/standard/tests/array/negative_index_empty_array.phpt From 38e2f03c6f0e8c6115ff7085814e576f510d6ee1 Mon Sep 17 00:00:00 2001 From: ColinHDev Date: Fri, 28 Apr 2023 18:10:47 +0200 Subject: [PATCH 5/7] Removed copy-pasted line from test file --- ext/standard/tests/array/negative_index_empty_array.phpt | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/standard/tests/array/negative_index_empty_array.phpt b/ext/standard/tests/array/negative_index_empty_array.phpt index 9f22e7a79e47..4637c189425d 100644 --- a/ext/standard/tests/array/negative_index_empty_array.phpt +++ b/ext/standard/tests/array/negative_index_empty_array.phpt @@ -10,7 +10,6 @@ $a[] = "after -5"; var_dump($a); ?> --EXPECT-- -bool(true) array(2) { [-5]=> string(2) "-5" From 7b671d83398ab63387e14677bb7d81b1848365c7 Mon Sep 17 00:00:00 2001 From: ColinHDev Date: Fri, 28 Apr 2023 19:04:04 +0200 Subject: [PATCH 6/7] Applying requested changes --- UPGRADING | 6 +++--- ext/standard/tests/array/negative_index_empty_array.phpt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/UPGRADING b/UPGRADING index 689ae9ababca..030a497662a8 100644 --- a/UPGRADING +++ b/UPGRADING @@ -39,8 +39,8 @@ PHP 8.3 UPGRADE NOTES inherited from the parent class. This will create a separate static property storage for the current class. This is analogous to adding the static property to the class directly without traits. - . Assigning a value to a negative index n in an empty array will now make sure that - the next index is n+1 and no longer default to 0. + . Assigning a value to a negative index n in an empty array will now make + sure that the next index is n+1 and no longer default to 0. - FFI: . C functions that have a return type of void now return null instead of @@ -97,7 +97,7 @@ PHP 8.3 UPGRADE NOTES . Changed DOMCharacterData::appendData() tentative return type to true. - Intl: - . datefmt_set_timezone (and its alias IntlDateformatter::setTimeZone) + . datefmt_set_timezone (and its alias IntlDateformatter::setTimeZone) now returns true on success, previously null was returned. . IntlBreakiterator::setText() now returns false on failure, previously null was returned. diff --git a/ext/standard/tests/array/negative_index_empty_array.phpt b/ext/standard/tests/array/negative_index_empty_array.phpt index 4637c189425d..322ac6e820ce 100644 --- a/ext/standard/tests/array/negative_index_empty_array.phpt +++ b/ext/standard/tests/array/negative_index_empty_array.phpt @@ -3,7 +3,7 @@ Test empty arrays with first added index being negative --FILE-- string(8) "after -5" -} \ No newline at end of file +} From 1a13270de4ce5e13b6e514d1d93f469f1b1d43a5 Mon Sep 17 00:00:00 2001 From: ColinHDev Date: Fri, 28 Apr 2023 19:14:39 +0200 Subject: [PATCH 7/7] I somehow accidentally removed this space --- UPGRADING | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADING b/UPGRADING index 030a497662a8..b7966f599af6 100644 --- a/UPGRADING +++ b/UPGRADING @@ -97,7 +97,7 @@ PHP 8.3 UPGRADE NOTES . Changed DOMCharacterData::appendData() tentative return type to true. - Intl: - . datefmt_set_timezone (and its alias IntlDateformatter::setTimeZone) + . datefmt_set_timezone (and its alias IntlDateformatter::setTimeZone) now returns true on success, previously null was returned. . IntlBreakiterator::setText() now returns false on failure, previously null was returned.