Mantis - Quercus
Viewing Issue Advanced Details
2543 major always 03-20-08 18:50 03-21-08 13:19
ckchris  
nam  
normal  
closed 3.1.5  
fixed  
none    
none 3.1.6  
0002543: Assignment not working properly?
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?

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]