2010年3月25日星期四

patch for amfphp AMF3 ByteArray serialization bug

Base on amfphp 1.9, there are bugs of AMF3 ByteArray serialization, if you want to send a ByteArray from PHP to flash, you will have to modify core/amf/io/AMFSerializer.php:writeAmf3ByteArray function.

Line 991:
Original code:
function writeAmf3ByteArray($d)
{
$this->writeByte(0x0C);
$this->writeAmf3String($d, true);
$this->writeAmf3ByteArrayBody($d);
}
change to:
function writeAmf3ByteArray($d)
{
$this->writeByte(0x0C);
$this->writeAmf3ByteArrayBody($d);
}
It fixed two issues:
1. writeAmf3String and writeAmf3ByteArrayBody writes ByteArray body content twice
2. writeAmf3String uses U29S-ref, ByteArray should be U29O-ref ( ref AMF3-spec)

Hope helpful