From 0bec2b9aef57da848a75b626598bb757d8b572f1 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Tue, 18 Mar 2025 13:40:47 -0600 Subject: [PATCH] Remove empty XML CDR files --- app/xml_cdr/resources/classes/xml_cdr.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index 58047adfd4..bf6422987e 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -314,8 +314,14 @@ */ public function xml_array($key, $leg, $xml_string) { + //set the directory + if (!empty($this->settings->get('switch', 'log'))) { + $xml_cdr_dir = $this->settings->get('switch', 'log').'/xml_cdr'; + } + //xml string is empty - if (empty($xml_string)) { + if (empty($xml_string) && !empty($xml_cdr_dir) && !empty($this->file)) { + unlink($xml_cdr_dir.'/'.$this->file); return false; } @@ -351,10 +357,6 @@ //load the string into an xml object $xml = simplexml_load_string($xml_string, 'SimpleXMLElement', LIBXML_NOCDATA); if ($xml === false) { - //set the directory - if (!empty($this->settings->get('switch', 'log'))) { - $xml_cdr_dir = $this->settings->get('switch', 'log').'/xml_cdr'; - } //failed to load the XML, move the XML file to the failed directory if (!empty($xml_cdr_dir)) {