Skip to content
Snippets Groups Projects
Commit aca7aba9 authored by Jared Hancock's avatar Jared Hancock
Browse files

Make phone ext optional for XML API

Previously, the @ext attribute for the phone number field was assumed to be
included. An XML payload without the @ext attribute would have been
corrupted to include only the first digit of the phone number, which would
fail validation.

This patch correctly handles the XML payload without the @ext attribute for
the phone number. Subsequently, the <phone_ext> element is now also valid
(and optional as well).

Fixes #670
parent 3e871610
No related branches found
No related tags found
No related merge requests found
...@@ -317,8 +317,9 @@ class ApiXmlDataParser extends XmlDataParser { ...@@ -317,8 +317,9 @@ class ApiXmlDataParser extends XmlDataParser {
if (!is_array($current)) if (!is_array($current))
return $current; return $current;
foreach ($current as $key=>&$value) { foreach ($current as $key=>&$value) {
if ($key == "phone") { if ($key == "phone" && is_array($value)) {
$current["phone_ext"] = $value["ext"]; # PHP [like] point if (isset($value['ext']))
$current["phone_ext"] = $value["ext"]; # PHP [like] point
$value = $value[":text"]; $value = $value[":text"];
} else if ($key == "alert") { } else if ($key == "alert") {
$value = (bool)$value; $value = (bool)$value;
...@@ -339,6 +340,7 @@ class ApiXmlDataParser extends XmlDataParser { ...@@ -339,6 +340,7 @@ class ApiXmlDataParser extends XmlDataParser {
$value = $this->fixup($value); $value = $this->fixup($value);
} }
} }
unset($value);
return $current; return $current;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment