From 232c566b67a21057e2185d576f784232ada2edb1 Mon Sep 17 00:00:00 2001 From: dante Date: Mon, 23 Oct 2017 15:01:21 -0400 Subject: [PATCH 1/4] HOR-3960 --- workflow/engine/classes/PmDynaform.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/workflow/engine/classes/PmDynaform.php b/workflow/engine/classes/PmDynaform.php index 3ad5a2cf0..2690e71b8 100644 --- a/workflow/engine/classes/PmDynaform.php +++ b/workflow/engine/classes/PmDynaform.php @@ -761,7 +761,12 @@ class PmDynaform } catch (Exception $e) { $this->context["action"] = "execute-sql" . $type; $this->context["exception"] = (array) $e; - \Bootstrap::registerMonolog("sqlExecution", 400, "Sql Execution", $this->context, $this->sysSys, "processmaker.log"); + \Bootstrap::registerMonolog("sqlExecution", + 400, + "Sql Execution", + $this->basicExceptionData($e), + $this->sysSys, + "processmaker.log"); } return $data; } @@ -2155,4 +2160,20 @@ class PmDynaform } } + /** + * Returns an array with the basic fields of the Exception class. It isn't returned any extra fields information + * of any derivated Exception class. This way we have a lightweight version of the exception data that can + * be used when logging the exception, for example. + * @param $e an Exception class derivate + * @return array + */ + private function basicExceptionData($e) + { + $result = []; + $result['code'] = $e->getCode(); + $result['file'] = $e->getFile(); + $result['line'] = $e->getLine(); + $result['message'] = $e->getMessage(); + return $result; + } } From aae6c8a61b6b42d8036723e1b63e2d8a6c062b53 Mon Sep 17 00:00:00 2001 From: dante Date: Mon, 23 Oct 2017 16:38:42 -0400 Subject: [PATCH 2/4] adding some SQLException fields with relevant info of the executed query --- workflow/engine/classes/PmDynaform.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/workflow/engine/classes/PmDynaform.php b/workflow/engine/classes/PmDynaform.php index 2690e71b8..d36597567 100644 --- a/workflow/engine/classes/PmDynaform.php +++ b/workflow/engine/classes/PmDynaform.php @@ -2174,6 +2174,15 @@ class PmDynaform $result['file'] = $e->getFile(); $result['line'] = $e->getLine(); $result['message'] = $e->getMessage(); + + if (property_exists($e, 'nativeError')) { + $result['nativeError'] = $e->getNativeError(); + } + + if (property_exists($e, 'userInfo')) { + $result['nativeError'] = $e->getUserInfo(); + } + return $result; } } From 672a3ee57e9b4f9d05dd015c29a05903b9cfde67 Mon Sep 17 00:00:00 2001 From: dante Date: Tue, 24 Oct 2017 10:01:38 -0400 Subject: [PATCH 3/4] adding the executed query in the exception --- workflow/engine/classes/PmDynaform.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/workflow/engine/classes/PmDynaform.php b/workflow/engine/classes/PmDynaform.php index d36597567..0b6c363da 100644 --- a/workflow/engine/classes/PmDynaform.php +++ b/workflow/engine/classes/PmDynaform.php @@ -764,7 +764,7 @@ class PmDynaform \Bootstrap::registerMonolog("sqlExecution", 400, "Sql Execution", - $this->basicExceptionData($e), + $this->basicExceptionData($e, $sql), $this->sysSys, "processmaker.log"); } @@ -2167,20 +2167,21 @@ class PmDynaform * @param $e an Exception class derivate * @return array */ - private function basicExceptionData($e) + private function basicExceptionData($e, $sql) { $result = []; $result['code'] = $e->getCode(); $result['file'] = $e->getFile(); $result['line'] = $e->getLine(); $result['message'] = $e->getMessage(); + $result['nativeQuery'] = $sql; if (property_exists($e, 'nativeError')) { $result['nativeError'] = $e->getNativeError(); } if (property_exists($e, 'userInfo')) { - $result['nativeError'] = $e->getUserInfo(); + $result['userInfo'] = $e->getUserInfo(); } return $result; From 6e6c9e021878489324974b06708f853a2998f854 Mon Sep 17 00:00:00 2001 From: dante Date: Tue, 24 Oct 2017 10:48:01 -0400 Subject: [PATCH 4/4] adding comment to function parameter --- workflow/engine/classes/PmDynaform.php | 1 + 1 file changed, 1 insertion(+) diff --git a/workflow/engine/classes/PmDynaform.php b/workflow/engine/classes/PmDynaform.php index 0b6c363da..1e4aa37e4 100644 --- a/workflow/engine/classes/PmDynaform.php +++ b/workflow/engine/classes/PmDynaform.php @@ -2165,6 +2165,7 @@ class PmDynaform * of any derivated Exception class. This way we have a lightweight version of the exception data that can * be used when logging the exception, for example. * @param $e an Exception class derivate + * @param $sql query that was executed when the exception was generated * @return array */ private function basicExceptionData($e, $sql)