Skip to content
Browse files

Fixed an error with multidimensional structures being passed through …

…to_array().
  • Loading branch information...
1 parent 1190734 commit 0a14e87811652c5ae1225aab0e6ff6a0a394ac06 @philsturgeon philsturgeon committed Mar 26, 2011
Showing with 12 additions and 5 deletions.
  1. +6 −0 application/controllers/api/example.php
  2. +6 −5 application/libraries/Format.php
View
6 application/controllers/api/example.php
@@ -80,4 +80,10 @@ function users_get()
$this->response(array('error' => 'Couldn\'t find any users!'), 404);
}
}
+
+
+ public function send_post()
+ {
+ var_dump($this->request->body);
+ }
}
View
11 application/libraries/Format.php
@@ -57,14 +57,15 @@ public function __construct($data = null, $from_type = null)
public function to_array($data = null)
{
- if ($data === null)
+ // If not just null, but nopthing is provided
+ if ($data === null and ! func_num_args())
{
$data = $this->_data;
}
$array = array();
- foreach ((array) $this->_data as $key => $value)
+ foreach ((array) $data as $key => $value)
{
if (is_object($value) or is_array($value))
{
@@ -81,9 +82,9 @@ public function to_array($data = null)
}
// Format XML for output
- public function to_xml($data = null, $structure = NULL, $basenode = 'xml')
+ public function to_xml($data = null, $structure = null, $basenode = 'xml')
{
- if ($data == null)
+ if ($data === null and ! func_num_args())
{
$data = $this->_data;
}
@@ -94,7 +95,7 @@ public function to_xml($data = null, $structure = NULL, $basenode = 'xml')
ini_set('zend.ze1_compatibility_mode', 0);
}
- if ($structure == NULL)
+ if ($structure === null)
{
$structure = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$basenode />");
}

0 comments on commit 0a14e87

Please sign in to comment.
Something went wrong with that request. Please try again.