google-code-backups / sabreamf

Automatically exported from code.google.com/p/sabreamf
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Class Mapping with not-local classes is lost while deserializing. #18

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
-- What steps will reproduce the problem?

1. Build a SabreAMF_OutputStream, with a SabreAMF_TypedObject object in it :
$amfResponse = new SabreAMF_Message();
$amfResponse->addBody(array(
  'target' => '/onResult',
  'response' => '',
  'data' => array(
    'myobj' => new SabreAMF_TypedObject('my.path.to.classname', 
       array('foo' => 'bar', 'baz' => 'foo')),
    'foo' => 'bar'
  )
);
$amfOutputStream = new SabreAMF_OutputStream();
$amfResponse->serialize($amfOutputStream);

2. Build a SabreAMF_InputStream from this SabreAMF_OutputStream:

$amfInputStream = new SabreAMF_InputStream($amfOutputStream->getRawData());
$amfResponse2 = new SabreAMF_Message();
$amfResponse2->deserialize($amfInputStream);

3. Watch the result :

$bodies = $amfResponse2->getBodies();
var_dump($bodies[0]['data']->body);

-- What is the expected output? What do you see instead?

I'm expecting something like :
array(
  'myobj' => new SabreAMF_TypedObject('my.path.to.classname', 
       array('foo' => 'bar', 'baz' => 'foo')),
  'foo' => 'bar'
)

But I get :

array(
  'myobj' => new SabreAMF_TypedObject(false, 
       array('foo' => 'bar', 'baz' => 'foo')),
  'foo' => 'bar'
)

The class of the SabreAMF_TypedObject is set to false.

-- What version of the product are you using? On what operating system?

Windows XP, SabreAMF 1.3

-- Please provide any additional information below.

I have a fix :

In SabreAMF_AMF0_Deserializer::readTypedObject(), replace :

if ($classname = $this->getLocalClassName($classname)) {
  $rObject = new $classname();
  $isMapped = true;
} else {
  $rObject = new SabreAMF_TypedObject($classname,null);
}

By :

if ($localClassName = $this->getLocalClassName($classname)) {
  $rObject = new $localClassName();
  $isMapped = true;
} else {
  $rObject = new SabreAMF_TypedObject($classname,null);
}

Original issue reported on code.google.com by thepurpl...@gmail.com on 1 Oct 2009 at 1:42

GoogleCodeExporter commented 8 years ago
You are correct. A fix is committed in r249. 

Thanks very much

Original comment by evert...@gmail.com on 1 Oct 2009 at 2:31