#28739 [Opn->Csd]: uasort and array_udiff doesn't work together
| From: | andrey@php.net | Date: | Sun, 11 Jul 2004 19:23:32 +0000 |
| Subject: | #28739 [Opn->Csd]: uasort and array_udiff doesn't work together | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-62047@lists.php.net to get a copy of this message | ||
ID: 28739
Updated by: andrey@php.net
Reported By: rodolfo at rodsoft dot org
-Status: Open
+Status: Closed
Bug Type: Arrays related
Operating System: linux 2.6.6
PHP Version: 5.0.0RC2
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
The reason :
array_*diff() and array_*intersect() not clearing the fci cache before
work
Previous Comments:
------------------------------------------------------------------------
[2004-06-11 17:06:17] rodolfo at rodsoft dot org
This problem apparently is in uasort. If you change uasort for, say,
uksort (and make code changes accordingly), the problem disappears.
------------------------------------------------------------------------
[2004-06-11 08:32:38] rodolfo at rodsoft dot org
Description:
------------
If you call uasort with one callback function and then call array_udiff
with another callback function, this last call will use first's
callback. If we first call array_udiff and then call uasort, everything
goes well.
Reproduce code:
---------------
<?
class p
{
public $x;
function __construct($x){$this->x=$x;}
}
function a(&$a, &$b){return $a->x - $b->x;}
function b(&$a, &$b){return $a->y - $b->y;}
$p1 = array(new p(2), new p(1), new p(0));
$p2 = array(new p(0), new p(2), new p(3));
uasort($p1, 'a');
print_r($p1);
echo "\n";
print_r(array_udiff($p1,$p2, 'b'));
?>
Expected result:
----------------
Notice: Undefined property: p::$y in tst.php on line 8
Actual result:
--------------
Array
(
[2] => p Object
(
[x] => 0
)
[1] => p Object
(
[x] => 1
)
[0] => p Object
(
[x] => 2
)
)
Array
(
[1] => p Object
(
[x] => 1
)
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28739&edit=1