From 25bdc4de0798ebb3bc1c9d34f315c47f6d07807c Mon Sep 17 00:00:00 2001 From: Sam Hanes Date: Sun, 1 Feb 2015 15:55:19 -0800 Subject: [PATCH] Allow specifying what should be a fatal error. Currently any nonzero status code received in the XML sent to `receiveResponseXML` is considered a fatal error and the QBWC session is torn down. That's incorrect according to the QBXML documentation, which says that codes 1-499 are informational and 500-999 are warnings. This adds a new configuration key, `status_error_threshold`, which is the minimum status code which should be considered a fatal error. To preserve reverse compatibility the default is set to 1. --- QuickBooks/WebConnector/Handlers.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/QuickBooks/WebConnector/Handlers.php b/QuickBooks/WebConnector/Handlers.php index 3348875d..697141d7 100755 --- a/QuickBooks/WebConnector/Handlers.php +++ b/QuickBooks/WebConnector/Handlers.php @@ -320,6 +320,8 @@ protected function _defaults($config) 'deny_reallyfast_timeout' => 600, 'masking' => true, + + 'status_error_threshold' => 1, // the lowest status code considered an error ); $config = array_merge($defaults, $config); @@ -347,6 +349,8 @@ protected function _defaults($config) $config['deny_reallyfast_logins'] = (boolean) $config['deny_reallyfast_logins']; $config['deny_reallyfast_timeout'] = (int) max(1, $config['deny_reallyfast_timeout']); + $config['status_error_threshold'] = (int) max(1, $config['status_error_threshold']); + return $config; } @@ -1287,8 +1291,9 @@ public function receiveResponseXML($obj) $this->_log('Incoming XML response: ' . $obj->response, $obj->ticket, QUICKBOOKS_LOG_DEBUG); // Check if we got a error message... - if (strlen($obj->message) or - $this->_extractStatusCode($obj->response)) // or an error code + if (strlen($obj->message) or + $this->_extractStatusCode($obj->response) + >= $this->_config['status_error_threshold']) // or an error code { //$this->_log('Extracted code[' . $this->_extractStatusCode($obj->response) . ']', $obj->ticket, QUICKBOOKS_LOG_DEBUG);