Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002125 [Quercus] minor always 10-27-07 01:27 08-11-08 15:39
Reporter koreth View Status public  
Assigned To ferg
Priority normal Resolution fixed  
Status closed   Product Version 3.1.3
Summary 0002125: Integer from MySQL query disappears on array append operation
Description I construct an array of results from a MySQL query:

$raw_thread_rows = array();
while ($row = mysql_fetch_assoc($ret)) {
  $raw_thread_rows[]= $row;
}

Then, later on, I iterate over that data trying to generate an array of values from one of the columns, and it fails. I add debug information:

$thread_ids = array();
foreach ($raw_thread_rows as $r) {
  error_log("Raw thread row = " . print_r($r, true));
  $thread_ids[] = $r['thread_id'];
  error_log("Thread ID array = " . print_r($thread_ids, true));
}

And here's the output I get (or at least the first few iterations of it):

Raw thread row = Array
(
    [user] => 500018751
    [thread_id] => 5963202122
    [last_update] => 1193435269
    [num_unread] => 0
)

Thread ID array = Array
(
    [0] =>
)

Raw thread row = Array
(
    [user] => 500018751
    [thread_id] => 5703323014
    [last_update] => 1193186680
    [num_unread] => 0
)

Thread ID array = Array
(
    [0] =>
    [1] =>
)

Raw thread row = Array
(
    [user] => 500018751
    [thread_id] => 5849902182
    [last_update] => 1192735312
    [num_unread] => 0
)

Thread ID array = Array
(
    [0] =>
    [1] =>
    [2] =>
)
Additional Information
Attached Files

- Relationships

- Notes
(0002399)
koreth
10-27-07 13:40

I have narrowed this down a bit more and I believe I mischaracterized it above. This only happens after objects from the MySQL query are stored into and then retrieved from our cache, meaning they pass through our custom object serializer.

It is actually a problem in StringBuilderValue.equals(). If you pass that function a BinaryBuilderValue representing the same string, it returns false. My serializer implementation doesn't differentiate between binary and string values because our PHP code expects to be able to serialize either binary or text data; in vanilla PHP the two are not distinct from one another and I didn't want any Unicode transformations happening under the covers to confuse things.

I think it should probably be the case that a StringBuilderValue and a BinaryBuilderValue that evaluate to the same value on the PHP side should test as equal. But in the meantime I will change my serializer to scan the data it's unserializing and produce a StringBuilderValue if there aren't any non-ASCII bytes in the value.
 
(0002400)
koreth
10-27-07 13:41

A little more detail, actually: what's happening is that ArrayValueImpl.get() is being passed a StringBuilderValue by the above code. It computes the correct hash value, but skips over the array entry it should be matching because the key happens to be a BinaryBuilderValue.
 
(0002403)
ferg
10-29-07 13:22

Actually, it's more complicated than that.

StringBuilderValue is the PHP5 string (or unicode.semantics='false')

BinaryBuilderValue is a PHP6 string with unicode.semantics='true'. It is not a PHP5 object at all.

In PHP6 with unicode.semantics=true, "a" === b"a" evaluates to false, and the following generates two distinct entries:

  $a = array();
  $a["a"] = 3;
  $a[b"a"] = 4;
  var_dump($a);

  array(2) {
    [u"a"]=>
    int(3)
    ["a"]=>
    int(4)
  }
 
(0002404)
koreth
10-29-07 13:26

In that case, maybe this is a documentation issue; the difference in semantics between binary and string values isn't described anywhere (that I saw) in the documentation describing how to interface between PHP and Java.
 

- Issue History
Date Modified Username Field Change
10-27-07 01:27 koreth New Issue
10-27-07 13:40 koreth Note Added: 0002399
10-27-07 13:41 koreth Note Added: 0002400
10-29-07 13:22 ferg Note Added: 0002403
10-29-07 13:26 koreth Note Added: 0002404
08-11-08 15:39 ferg Assigned To  => ferg
08-11-08 15:39 ferg Status new => closed
08-11-08 15:39 ferg Resolution open => fixed
08-11-08 15:39 ferg Fixed in Version  => 3.2.1


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