From d60a9e40fa4315fb155b38a38d839870bfc515ba Mon Sep 17 00:00:00 2001 From: donal72 Date: Fri, 2 Nov 2007 00:11:23 +0000 Subject: [PATCH] More error info about XML parse failures --- mnet/xmlrpc/xmlparser.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/mnet/xmlrpc/xmlparser.php b/mnet/xmlrpc/xmlparser.php index 0c9b9b5ed0..1d74381d25 100644 --- a/mnet/xmlrpc/xmlparser.php +++ b/mnet/xmlrpc/xmlparser.php @@ -94,7 +94,23 @@ class mnet_encxml_parser { // Parse failed $errcode = xml_get_error_code($this->parser); $errstring = xml_error_string($errcode); - $this->error[] = array('code' => $errcode, 'string' => $errstring); + $lineno = xml_get_current_line_number($this->parser); + if ($lineno !== false) { + $error = array('lineno' => $lineno); + $lineno--; // Line numbering starts at 1. + while ($lineno > 0) { + $data = strstr($data, "\n"); + $lineno--; + } + $data .= "\n"; // In case there's only one line (no newline) + $line = substr($data, 0, strpos($data, "\n")); + $error['code'] = $errcode; + $error['string'] = $errstring; + $error['line'] = $line; + $this->error[] = $error; + } else { + $this->error[] = array('code' => $errcode, 'string' => $errstring); + } } if (count($this->cipher) > 0) { -- 2.39.5