]> git.mxchange.org Git - friendica.git/commitdiff
Fix root element containing only text in api_create_xml()
authorHypolite Petovan <mrpetovan@gmail.com>
Sun, 1 Jul 2018 18:40:56 +0000 (14:40 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Mon, 2 Jul 2018 11:48:42 +0000 (07:48 -0400)
include/api.php

index 90212a6c3a6bae23d2a47d6ec8c21bcb31338d3a..029f45257fc154f00d9c22a2ffbcb0adf21977ef 100644 (file)
@@ -885,7 +885,6 @@ function api_create_xml(array $data, $root_element)
 {
        $childname = key($data);
        $data2 = array_pop($data);
-       $key = key($data2);
 
        $namespaces = ["" => "http://api.twitter.com",
                                "statusnet" => "http://status.net/schema/api/1/",
@@ -898,18 +897,19 @@ function api_create_xml(array $data, $root_element)
        }
 
        if (is_array($data2)) {
+               $key = key($data2);
                api_walk_recursive($data2, "api_reformat_xml");
-       }
 
-       if ($key == "0") {
-               $data4 = [];
-               $i = 1;
+               if ($key == "0") {
+                       $data4 = [];
+                       $i = 1;
 
-               foreach ($data2 as $item) {
-                       $data4[$i++ . ":" . $childname] = $item;
-               }
+                       foreach ($data2 as $item) {
+                               $data4[$i++ . ":" . $childname] = $item;
+                       }
 
-               $data2 = $data4;
+                       $data2 = $data4;
+               }
        }
 
        $data3 = [$root_element => $data2];