Bug #54140 [Opn]: array_merge() break keys during merge
Edit report at http://bugs.php.net/bug.php?id=54140&edit=1 ID: 54140 User updated by:forjest at gmail dot com Reported by:forjest at gmail dot com Summary:array_merge() break keys during merge Status: Open Type: Bug Package:Arrays related -Operating System: +Operating System: *Nix PHP Version:5.3.5 Block user comment: N Private report: N New Comment: Works as expected on Windows platform. Previous Comments: [2011-03-02 18:21:06] forjest at gmail dot com Description: array_merge interprets string keys, containing only digits as numeric keys, if numeric overflow not reached. String keys should works as strings regarless of their contents. Test script: --- var_dump(array_merge(array('t777'=> array("I'm a string"; var_dump(array_merge(array("42424242"=> array("I'm a string of digits"; var_dump(array_merge(array("7"=> array("I'm string of digits too"; var_dump(is_string("42424242")); var_dump(is_string(42424242)); var_dump(is_string("7")); Expected result: array(1) { ["t777"]=> array(1) { [0]=> string(12) "I'm a string" } } array(1) { ["42424242"]=> array(1) { [0]=> string(22) "I'm a string of digits" } } array(1) { ["7"]=> array(1) { [0]=> string(24) "I'm string of digits too" } } bool(true) bool(false) bool(true) Actual result: -- array(1) { ["t777"]=> array(1) { [0]=> string(12) "I'm a string" } } array(1) { [0]=> array(1) { [0]=> string(22) "I'm a string of digits" } } array(1) { ["7"]=> array(1) { [0]=> string(24) "I'm string of digits too" } } bool(true) bool(false) bool(true) -- Edit this bug report at http://bugs.php.net/bug.php?id=54140&edit=1
[PHP-BUG] Bug #54140 [NEW]: array_merge() break keys during merge
From: Operating system: PHP version: 5.3.5 Package: Arrays related Bug Type: Bug Bug description:array_merge() break keys during merge Description: array_merge interprets string keys, containing only digits as numeric keys, if numeric overflow not reached. String keys should works as strings regarless of their contents. Test script: --- var_dump(array_merge(array('t777'=> array("I'm a string"; var_dump(array_merge(array("42424242"=> array("I'm a string of digits"; var_dump(array_merge(array("7"=> array("I'm string of digits too"; var_dump(is_string("42424242")); var_dump(is_string(42424242)); var_dump(is_string("7")); Expected result: array(1) { ["t777"]=> array(1) { [0]=> string(12) "I'm a string" } } array(1) { ["42424242"]=> array(1) { [0]=> string(22) "I'm a string of digits" } } array(1) { ["7"]=> array(1) { [0]=> string(24) "I'm string of digits too" } } bool(true) bool(false) bool(true) Actual result: -- array(1) { ["t777"]=> array(1) { [0]=> string(12) "I'm a string" } } array(1) { [0]=> array(1) { [0]=> string(22) "I'm a string of digits" } } array(1) { ["7"]=> array(1) { [0]=> string(24) "I'm string of digits too" } } bool(true) bool(false) bool(true) -- Edit bug report at http://bugs.php.net/bug.php?id=54140&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54140&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54140&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54140&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54140&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54140&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54140&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54140&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54140&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54140&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54140&r=support Expected behavior: http://bugs.php.net/fix.php?id=54140&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54140&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54140&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54140&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54140&r=php4 Daylight Savings:http://bugs.php.net/fix.php?id=54140&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54140&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54140&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54140&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54140&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54140&r=mysqlcfg
#41372 [Bgs->Opn]: Internal pointer of source array resets during array copying
ID: 41372 User updated by: forjest at gmail dot com Reported By: forjest at gmail dot com -Status: Bogus +Status: Open Bug Type: Arrays related Operating System: WinXP, Linux PHP Version: 4.4.7 New Comment: I'm described problem, that is not foreach related. Just 1. Straight copy from one global scope variable to another 2. Copy from current runing context to global variable. Not iterating local varibale after copying element of global array. This is another bug, but may be from same "family". And please remember another one http://bugs.php.net/bug.php?id=37715 Problem appeared at 4.4.2 and 5.1.2 and was reported year ago... May be I'm described duplicate of "This is expected and not going to be changed" bug instead of assigned 'foreach' bug? Previous Comments: [2007-05-16 13:01:18] [EMAIL PROTECTED] Duplicate of bug #40509. -------- [2007-05-12 10:10:17] forjest at gmail dot com /*for simple case just wrap array in some array function. That will cause small overhead, but at least save your internal pointer*/ $Foo = array('val1', 'val2', 'val3'); end($Foo); var_dump(key($Foo)); $AllOkay = array_merge($Foo); var_dump(key($Foo)); -- /*But to make immune running context for error handler function nothing helps, except ugly serialize/unserialize solution*/ error_reporting(E_ALL); function TestErrorHandler($severity, $message, $filename, $line, $super_globals) { global $foo; $foo = unserialize(serialize($super_globals)); } class Test { function run() { $Res = array('val1', 'val2', 'val3'); end($Res); var_dump(key($Res)); HEY;//raise notice error var_dump(key($Res)); } } $test = new Test(); set_error_handler('TestErrorHandler'); $test-> run(); -------- [2007-05-12 08:32:17] forjest at gmail dot com Description: Bug first appeared in 4.4.2. Version 4.4.1 works okay. 5.1.4, 5.2.1 has this bug too. - Seems algorithm of array copying was changed at 4.4.2 and 5.1.2 versions. - This behavior cause problems in unexpected situations such as error handling functions, when array pointer reseted due copying from another array which reference to it. Reproduce code: --- $Foo = array('val1', 'val2', 'val3'); end($Foo); var_dump(key($Foo)); $MagicInternalPointerResetter = $Foo; var_dump(key($Foo)); -- Code describing unexpected results of this behavior listed here: http://www.pastebin.ru/10226 Expected result: int(2) int(2) Actual result: -- int(2) int(0) -- Edit this bug report at http://bugs.php.net/?id=41372&edit=1
#41372 [Opn]: Internal pointer of source array resets during array copying
ID: 41372 User updated by: forjest at gmail dot com Reported By: forjest at gmail dot com Status: Open Bug Type: Arrays related Operating System: WinXP, Linux PHP Version: 4.4.7 New Comment: /*for simple case just wrap array in some array function. That will cause small overhead, but at least save your internal pointer*/ $Foo = array('val1', 'val2', 'val3'); end($Foo); var_dump(key($Foo)); $AllOkay = array_merge($Foo); var_dump(key($Foo)); -- /*But to make immune running context for error handler function nothing helps, except ugly serialize/unserialize solution*/ error_reporting(E_ALL); function TestErrorHandler($severity, $message, $filename, $line, $super_globals) { global $foo; $foo = unserialize(serialize($super_globals)); } class Test { function run() { $Res = array('val1', 'val2', 'val3'); end($Res); var_dump(key($Res)); HEY;//raise notice error var_dump(key($Res)); } } $test = new Test(); set_error_handler('TestErrorHandler'); $test-> run(); Previous Comments: -------------------- [2007-05-12 08:32:17] forjest at gmail dot com Description: Bug first appeared in 4.4.2. Version 4.4.1 works okay. 5.1.4, 5.2.1 has this bug too. - Seems algorithm of array copying was changed at 4.4.2 and 5.1.2 versions. - This behavior cause problems in unexpected situations such as error handling functions, when array pointer reseted due copying from another array which reference to it. Reproduce code: --- $Foo = array('val1', 'val2', 'val3'); end($Foo); var_dump(key($Foo)); $MagicInternalPointerResetter = $Foo; var_dump(key($Foo)); -- Code describing unexpected results of this behavior listed here: http://www.pastebin.ru/10226 Expected result: int(2) int(2) Actual result: -- int(2) int(0) -- Edit this bug report at http://bugs.php.net/?id=41372&edit=1
#41372 [NEW]: Internal pointer of source array resets during array copying
From: forjest at gmail dot com Operating system: WinXP, Linux PHP version: 4.4.7 PHP Bug Type: Arrays related Bug description: Internal pointer of source array resets during array copying Description: Bug first appeared in 4.4.2. Version 4.4.1 works okay. 5.1.4, 5.2.1 has this bug too. - Seems algorithm of array copying was changed at 4.4.2 and 5.1.2 versions. - This behavior cause problems in unexpected situations such as error handling functions, when array pointer reseted due copying from another array which reference to it. Reproduce code: --- $Foo = array('val1', 'val2', 'val3'); end($Foo); var_dump(key($Foo)); $MagicInternalPointerResetter = $Foo; var_dump(key($Foo)); -- Code describing unexpected results of this behavior listed here: http://www.pastebin.ru/10226 Expected result: int(2) int(2) Actual result: -- int(2) int(0) -- Edit bug report at http://bugs.php.net/?id=41372&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41372&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41372&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41372&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41372&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41372&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41372&r=needtrace Need Reproduce Script:http://bugs.php.net/fix.php?id=41372&r=needscript Try newer version:http://bugs.php.net/fix.php?id=41372&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41372&r=support Expected behavior:http://bugs.php.net/fix.php?id=41372&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41372&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41372&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41372&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41372&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41372&r=dst IIS Stability:http://bugs.php.net/fix.php?id=41372&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41372&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41372&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41372&r=nozend MySQL Configuration Error:http://bugs.php.net/fix.php?id=41372&r=mysqlcfg