ID: 46561
Updated by: [EMAIL PROTECTED]
Reported By: jian at theorchard dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Windows/Linux
PHP Version: 5.2.6
New Comment:
Does this code really adds an element with key 0x80000000 and then an
other with 0x7FFFFFFF ?
There is many possible work arounds for this issue. The simplest one is
probably to do $this->drives[$row['drive_id']] = $row['drive_id'].
Previous Comments:
------------------------------------------------------------------------
[2008-11-14 20:52:33] jian at theorchard dot com
Ok. So the fix was to add the missing warning. Then the warnings I
got from my code doesn't apply to this fix. Ok, here's what happened in
my case. I have a small class that is like this below.
<?
class myClass{
public $drives = array();
public function get_drives(){
$sql = 'CALL some_stored_procedure()';
$result = mysql_query($sql);
if(mysql_num_rows($result)){
while($row = mysql_fetch_array($result)){
$this->drives[] = $row['drive_id'];
}
}
}
}
?>
Line "$this->drives[] = $row['drive_id'];" throws out the same warning.
I'm scracthing my head trying to resolve this. Any ideas?
------------------------------------------------------------------------
[2008-11-14 18:24:52] [EMAIL PROTECTED]
What was fixed in #41685 is that array_push() was not producing
warnings in this case (the fix has added the warning in array_push()).
------------------------------------------------------------------------
[2008-11-13 00:27:55] jian at theorchard dot com
Description:
------------
PHP Bugs: #41685 was not fixed in version 5.2.5 and 5.2.6. I was able
to reproduce the problem with this exact code from rob_nicholson at uk
dot ibm dot com's example.
Reproduce code:
---------------
<?
$arr = array();
$arr[0x80000000]=8;
$arr[0x7FFFFFFF]=1;
$arr[]="foo";
?>
Expected result:
----------------
array(3) {
[-2147483648]=>
int(8)
[2147483647]=>
int(1)
[0]=>
string(3) "foo"
}
Actual result:
--------------
PHP Warning: array_push(): Cannot add element to the array as the next
element is already occupied in C:\test.php on line 6
array(2) {
[-2147483648]=>
int(8)
[2147483647]=>
int(1)
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46561&edit=1