Fix root element containing only text in api_create_xml()

This commit is contained in:
Hypolite Petovan 2018-07-01 14:40:56 -04:00
parent 62eba48679
commit dde61a77a4

View file

@ -885,7 +885,6 @@ function api_create_xml(array $data, $root_element)
{ {
$childname = key($data); $childname = key($data);
$data2 = array_pop($data); $data2 = array_pop($data);
$key = key($data2);
$namespaces = ["" => "http://api.twitter.com", $namespaces = ["" => "http://api.twitter.com",
"statusnet" => "http://status.net/schema/api/1/", "statusnet" => "http://status.net/schema/api/1/",
@ -898,8 +897,8 @@ function api_create_xml(array $data, $root_element)
} }
if (is_array($data2)) { if (is_array($data2)) {
$key = key($data2);
api_walk_recursive($data2, "api_reformat_xml"); api_walk_recursive($data2, "api_reformat_xml");
}
if ($key == "0") { if ($key == "0") {
$data4 = []; $data4 = [];
@ -911,6 +910,7 @@ function api_create_xml(array $data, $root_element)
$data2 = $data4; $data2 = $data4;
} }
}
$data3 = [$root_element => $data2]; $data3 = [$root_element => $data2];