Hi,

recently we encountered a problem with thrift_protocol PHP-extension:
it takes parameters "by-reference" and casts them into proper types.

Probably example will explain what is possibly wrong:

<?php
$str = 100;
var_dump($str);
echo rtrim($str), "\n"; // expects string
var_dump($str);
?>

and output is as expected, type of $str isn't changed

int(100)
100
int(100)


But consider we have Thrift service with function specified as:

void foo(1:string s)

and we use it similarly

<?php
// ... initialize thrift
$str = 100;
var_dump($str);
$client->foo($str);
var_dump($str);
?>

results

int(100)
string(3) "100"

=> type of $str is changed!

I looked through the extension code and there's convert_to_* calls on the input
variables, which causes this suprising behaviour. I also tried to replace
convert_to_* calls in binary_serialize with _ex counterparts, but something
went completely wrong.

Is this expected behaviour or should this be considered as a bug?


-- 
Oleg Grenrus

Reply via email to