From aca7aba9ab4fee186c611360eba88a87f52ef74e Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 19 Aug 2013 13:17:59 +0000 Subject: [PATCH] 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 --- include/class.api.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/class.api.php b/include/class.api.php index b254d6ce6..d83a320b7 100644 --- a/include/class.api.php +++ b/include/class.api.php @@ -317,8 +317,9 @@ class ApiXmlDataParser extends XmlDataParser { if (!is_array($current)) return $current; foreach ($current as $key=>&$value) { - if ($key == "phone") { - $current["phone_ext"] = $value["ext"]; # PHP [like] point + if ($key == "phone" && is_array($value)) { + if (isset($value['ext'])) + $current["phone_ext"] = $value["ext"]; # PHP [like] point $value = $value[":text"]; } else if ($key == "alert") { $value = (bool)$value; @@ -339,6 +340,7 @@ class ApiXmlDataParser extends XmlDataParser { $value = $this->fixup($value); } } + unset($value); return $current; } -- GitLab