Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002543 [Quercus] major always 03-20-08 18:50 03-21-08 13:19
Reporter ckchris View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 3.1.5
Summary 0002543: Assignment not working properly?
Description This is a direct copy of a function code from phpbb3's includes/functions_content.php, part of the class bitfield:

        function set($n)
        {
                $byte = $n >> 3;
                $bit = 7 - ($n & 7);

                if (strlen($this->data) >= $byte + 1)
                {
resin_debug("bit val: " . ord(chr(96) | chr(1)));
$vall = $this->data[$byte] | chr(1 << $bit);
resin_debug("ord: " . ord($vall));
                        //$this->data[$byte] = $this->data[$byte] | chr(1 << $bit);
                        $this->data[$byte] = $vall;
resin_debug(ord($this->data[$byte]));
                }
                else
                {
                        $this->data .= str_repeat("\0", $byte - strlen($this->data));
                        $this->data .= chr(1 << $bit);
                }
        }

I have sprinkled some resin debug statements for testing.

Input values are: 1, 2, 7

Output of debugging is:

[2008/03/20 19:41:02.899] INFO [com.caucho.quercus.lib.MiscModule] bit val: 97
[2008/03/20 19:41:02.900] INFO [com.caucho.quercus.lib.MiscModule] ord: 96
[2008/03/20 19:41:02.901] INFO [com.caucho.quercus.lib.MiscModule] 64
[2008/03/20 19:41:02.901] INFO [com.caucho.quercus.lib.MiscModule] bit val: 97
[2008/03/20 19:41:02.902] INFO [com.caucho.quercus.lib.MiscModule] ord: 65
[2008/03/20 19:41:02.903] INFO [com.caucho.quercus.lib.MiscModule] 64
[2008/03/20 19:41:02.899] INFO [com.caucho.quercus.lib.MiscModule] bit val: 97
[2008/03/20 19:41:02.900] INFO [com.caucho.quercus.lib.MiscModule] ord: 96
[2008/03/20 19:41:02.900] INFO [com.caucho.quercus.lib.MiscModule] 64
[2008/03/20 19:41:02.901] INFO [com.caucho.quercus.lib.MiscModule] bit val: 97
[2008/03/20 19:41:02.902] INFO [com.caucho.quercus.lib.MiscModule] ord: 65
[2008/03/20 19:41:02.903] INFO [com.caucho.quercus.lib.MiscModule] 64

So here's the strange thing. the output of the second statement with "ord: 65" shows the correct value.

Yet, when $vall is assigned to $this->data[$byte], the value changed.

Is there an assignment problem here?
Additional Information
Attached Files

- Relationships

- Notes
(0002869)
ckchris
03-20-08 19:17

I am not sure but I narrowed it down to the following problem with the expressions:

With the above code, somehow reaching into the array data does not let me change/modify the character at the index. I changed the index to 0

$this->data[0] = "a"; <====== doesn't change $this->data at all
$this->data = "a"; <======== changes the data no problem
 
(0002870)
ckchris
03-20-08 19:32

I figured out the problem. It appears that once a string is created, I am unable to change a character using the array-index approach. Under PHP, I am allowed to modify the string using array indexes.

$blah = "llllll";
$blah[0] = "a";
resin_debug($blah); <==== still prints "llllll"
 
(0002872)
ckchris
03-20-08 20:00

I am currently running the latest snapshot of quercus, date today, March 20, 2008. Checked out of the SVN about 6 hours ago from the posting of this comment I am writing right now.
 
(0002874)
nam
03-21-08 13:19

php/03m[b-d]
php/04a[0-2]
php/0i2[4-5]
php/0j2[4-5]
 

- Issue History
Date Modified Username Field Change
03-20-08 18:50 ckchris New Issue
03-20-08 18:50 ckchris Issue Monitored: ckchris
03-20-08 19:17 ckchris Note Added: 0002869
03-20-08 19:32 ckchris Note Added: 0002870
03-20-08 19:45 nam Status new => assigned
03-20-08 19:45 nam Assigned To  => nam
03-20-08 20:00 ckchris Note Added: 0002872
03-21-08 13:19 nam Status assigned => closed
03-21-08 13:19 nam Note Added: 0002874
03-21-08 13:19 nam Resolution open => fixed
03-21-08 13:19 nam Fixed in Version  => 3.1.6


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
36 total queries executed.
29 unique queries executed.
Powered by Mantis Bugtracker