mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
There are 2 issues: 1. When a MULTISORT_ABORT happens, it frees func, but func may point to ARRAYG(multisort_func), which would be a problem with nested invocations as it can destroy that of the "parent" invocation. To solve this, delay assigning to the globals. 2. The old globals were not restored which means that nested invocations with different flags will cause a wrong sorting function to be used. Closes GH-19319.
41 lines
938 B
PHP
41 lines
938 B
PHP
--TEST--
|
|
GH-19300 (Nested array_multisort invocation with error breaks) - error variation
|
|
--FILE--
|
|
<?php
|
|
|
|
function error_handle($level, $message, $file = '', $line = 0){
|
|
try {
|
|
array_multisort($a, SORT_ASC); // Trigger multisort abort
|
|
} catch (TypeError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
}
|
|
set_error_handler('error_handle');
|
|
|
|
$inputs = [
|
|
new stdClass,
|
|
new stdClass,
|
|
new stdClass,
|
|
];
|
|
|
|
var_dump(array_multisort($inputs, SORT_NUMERIC));
|
|
var_dump($inputs);
|
|
?>
|
|
--EXPECT--
|
|
array_multisort(): Argument #1 ($array) must be an array or a sort flag
|
|
array_multisort(): Argument #1 ($array) must be an array or a sort flag
|
|
array_multisort(): Argument #1 ($array) must be an array or a sort flag
|
|
array_multisort(): Argument #1 ($array) must be an array or a sort flag
|
|
bool(true)
|
|
array(3) {
|
|
[0]=>
|
|
object(stdClass)#1 (0) {
|
|
}
|
|
[1]=>
|
|
object(stdClass)#2 (0) {
|
|
}
|
|
[2]=>
|
|
object(stdClass)#3 (0) {
|
|
}
|
|
}
|