Skip to content

array_unique: explain what the 7.2 rebuild actually changes - #5825

Merged
lacatoire merged 1 commit into
php:masterfrom
lacatoire:fix/array-unique-7.2-changelog
Sep 2, 2026
Merged

array_unique: explain what the 7.2 rebuild actually changes#5825
lacatoire merged 1 commit into
php:masterfrom
lacatoire:fix/array-unique-7.2-changelog

Conversation

@lacatoire

@lacatoire lacatoire commented Sep 2, 2026

Copy link
Copy Markdown
Member

The 7.2.0 changelog entry mentioned array packing, an engine detail, and left "different numeric indexes" unexplained. The 7.2 migration guide carried the same sentence, so both are updated.

The keys of the returned elements are the same before and after 7.2: the old implementation copied the array and removed the non-unique elements, the current one adds them to a new array with zend_hash_index_add_new, keeping the original key either way.

What differs is the index generated when an element is appended to the result afterwards, and only when the element carrying the largest integer key was among the removed duplicates. The counter behind $a[] = is never lowered by a deletion, so the old copy kept the value inherited from the input.

Fixes: #4370

The 7.2.0 entry mentioned array packing, an engine detail, and left
'different numeric indexes' unexplained. The keys of the returned
elements are unchanged; what differs is the index generated when an
element is appended afterwards, and only when the element carrying the
largest integer key was among the removed duplicates.

The 7.2 migration guide carried the same sentence and is updated too.
@lacatoire
lacatoire force-pushed the fix/array-unique-7.2-changelog branch from 8f122c5 to d8ca2a2 Compare September 2, 2026 14:37
@lacatoire
lacatoire merged commit 5e26d11 into php:master Sep 2, 2026
2 checks passed
@lacatoire
lacatoire deleted the fix/array-unique-7.2-changelog branch September 2, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

To clarify the note of the array_unique function

1 participant