ID:               46561
 User updated by:  jian at theorchard dot com
 Reported By:      jian at theorchard dot com
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: *
 PHP Version:      5.2.6
 New Comment:

I'm not sure if this code really adds an element with key 0x80000000
and then an other with 0x7FFFFFFF?  It's very hard to reproduce it.  It
only has happened twice.  Your suggestion should fix the problem.  But I
was so surprised that I got that warning.


Previous Comments:
------------------------------------------------------------------------

[2008-11-15 15:26:29] [EMAIL PROTECTED]

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'].


------------------------------------------------------------------------

[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

Reply via email to