Edit report at https://bugs.php.net/bug.php?id=72805&edit=1
ID: 72805
User updated by: mitrickx at mail dot ru
Reported by: mitrickx at mail dot ru
Summary: array diff bug
-Status: Open
+Status: Closed
Type: Bug
Package: *General Issues
Operating System: Windows,Debian
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Sorry. My mistake
Previous Comments:
------------------------------------------------------------------------
[2016-08-10 14:12:15] mitrickx at mail dot ru
Description:
------------
$item = array (
'id' => '21',
'sid' => NULL,
'parent_id' => '20',
'storage_id' => '10',
'name' =>
'a_folder_filesFileModelTesttestMoveSmallTreeIntoFolder57ab2d09bfa17',
'left_key' => '4',
'right_key' => '5',
'depth' => '1',
'contact_id' => '504',
'size' => '0',
'count' => '1',
'ext' => NULL,
'type' => 'folder',
'create_datetime' => '2016-08-10 16:32:57',
'update_datetime' => '2016-08-10 16:32:57',
'hash' => '75eaadd1fbbd5ecf467f7e7bc2bd8e61',
'source_id' => '4',
'source_inner_id' => NULL,
'source_path' => NULL,
'mark' => NULL,
'in_copy_process' => '0',
);
$prev_item = array (
'id' => '21',
'sid' => NULL,
'parent_id' => '20',
'storage_id' => '10',
'name' =>
'a_folder_filesFileModelTesttestMoveSmallTreeIntoFolder57ab2d09bfa17',
'left_key' => '4',
'right_key' => '5',
'depth' => '1',
'contact_id' => '504',
'size' => '0',
'count' => '1',
'ext' => NULL,
'type' => 'folder',
'create_datetime' => '2016-08-10 16:32:57',
'update_datetime' => '2016-08-10 16:32:57',
'hash' => NULL,
'source_id' => '0',
'source_inner_id' => NULL,
'source_path' => NULL,
'mark' => NULL,
'in_copy_process' => '0',
);
var_dump(array_diff($item, $prev_item));
// Incorrect!
// Array
// (
// hash => '75eaadd1fbbd5ecf467f7e7bc2bd8e61'
// )
// Must be
// Array
// (
// hash => '75eaadd1fbbd5ecf467f7e7bc2bd8e61'
// source_id => '4'
// )
// but when we change a little. 'source_id' was '4', now it is '6'
$item['source_id'] = '6';
var_dump(array_diff($item, $prev_item));
// Correct
// Array
// (
// hash => '75eaadd1fbbd5ecf467f7e7bc2bd8e61'
// source_id => '6'
// )
// and come back to '4' again
$item['source_id'] = '4';
// Tada!! Lol!! :) Incorrect again
// Array
// (
// hash => '75eaadd1fbbd5ecf467f7e7bc2bd8e61'
// )
// just play with digits. Try '1', '2', '3', '4',
'5', '6'
Test script:
---------------
// See bellow
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72805&edit=1