[php-src] PR #24453: Fix array_udiff_assoc() and array_uintersect_assoc() clobbering the user comparison callback
| From: | lacatoire | Date: | Tue, 20 Oct 2026 07:45:30 +0000 |
| Subject: | [php-src] PR #24453: Fix array_udiff_assoc() and array_uintersect_assoc() clobbering the user comparison callback | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-39631@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/24453
Author: lacatoire
array_udiff_assoc() and array_uintersect_assoc() parse the callback
straight into BG(user_compare_fci) and never restore the previous value, unlike the
other array_u*() functions. A comparison callback that calls one of them is replaced by
the inner callback for the rest of the sort.
Split out of #24426, where the review pointed out these two functions.
### To reproduce on PHP 8.4
```php
<?php
$sorted = [3, 1, 2];
usort($sorted, function ($a, $b) {
echo "outer\n";
array_udiff_assoc([1], [1], function ($x, $y) { echo "inner\n"; return $x <=>
$y; });
return $a <=> $b;
});
```
php repro.php
Before: outer inner inner inner (the outer comparator is replaced after the first call)
After: outer inner outer inner outer inner