Skip to content

Commit

Permalink
Controller data is now set to an array instead of Xml object if reque…
Browse files Browse the repository at this point in the history
…st content type is 'application/xml'
  • Loading branch information
ADmad committed Dec 31, 2009
1 parent 41e6fdf commit 5f987a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cake/libs/controller/components/request_handler.php
Expand Up @@ -219,10 +219,10 @@ function startup(&$controller) {
}
$xml = new Xml(trim(file_get_contents('php://input')));

if (is_object($xml->child('data')) && count($xml->children) == 1) {
$controller->data = $xml->child('data');
if (count($xml->children) == 1 && is_object($dataNode = $xml->child('data'))) {
$controller->data = $dataNode->toArray();
} else {
$controller->data = $xml;
$controller->data = $xml->toArray();
}
}
}
Expand Down
Expand Up @@ -241,8 +241,8 @@ function testStartupCallback() {
$_SERVER['REQUEST_METHOD'] = 'PUT';
$_SERVER['CONTENT_TYPE'] = 'application/xml';
$this->RequestHandler->startup($this->Controller);
$this->assertTrue(is_object($this->Controller->data));
$this->assertEqual(strtolower(get_class($this->Controller->data)), 'xml');
$this->assertTrue(is_array($this->Controller->data));
$this->assertFalse(is_object($this->Controller->data));
}

/**
Expand All @@ -254,8 +254,8 @@ function testStartupCallbackCharset() {
$_SERVER['REQUEST_METHOD'] = 'PUT';
$_SERVER['CONTENT_TYPE'] = 'application/xml; charset=UTF-8';
$this->RequestHandler->startup($this->Controller);
$this->assertTrue(is_object($this->Controller->data));
$this->assertEqual(strtolower(get_class($this->Controller->data)), 'xml');
$this->assertTrue(is_array($this->Controller->data));
$this->assertFalse(is_object($this->Controller->data));
}

/**
Expand Down

0 comments on commit 5f987a4

Please sign in to comment.