Skip to content

Commit 0a14e87

Browse files
author
Phil Sturgeon
committed
Fixed an error with multidimensional structures being passed through to_array().
1 parent 1190734 commit 0a14e87

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

application/controllers/api/example.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,10 @@ function users_get()
8080
$this->response(array('error' => 'Couldn\'t find any users!'), 404);
8181
}
8282
}
83+
84+
85+
public function send_post()
86+
{
87+
var_dump($this->request->body);
88+
}
8389
}

application/libraries/Format.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ public function __construct($data = null, $from_type = null)
5757

5858
public function to_array($data = null)
5959
{
60-
if ($data === null)
60+
// If not just null, but nopthing is provided
61+
if ($data === null and ! func_num_args())
6162
{
6263
$data = $this->_data;
6364
}
6465

6566
$array = array();
6667

67-
foreach ((array) $this->_data as $key => $value)
68+
foreach ((array) $data as $key => $value)
6869
{
6970
if (is_object($value) or is_array($value))
7071
{
@@ -81,9 +82,9 @@ public function to_array($data = null)
8182
}
8283

8384
// Format XML for output
84-
public function to_xml($data = null, $structure = NULL, $basenode = 'xml')
85+
public function to_xml($data = null, $structure = null, $basenode = 'xml')
8586
{
86-
if ($data == null)
87+
if ($data === null and ! func_num_args())
8788
{
8889
$data = $this->_data;
8990
}
@@ -94,7 +95,7 @@ public function to_xml($data = null, $structure = NULL, $basenode = 'xml')
9495
ini_set('zend.ze1_compatibility_mode', 0);
9596
}
9697

97-
if ($structure == NULL)
98+
if ($structure === null)
9899
{
99100
$structure = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$basenode />");
100101
}

0 commit comments

Comments
 (0)