jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/333041 )

Change subject: Move exception trace into log data
......................................................................


Move exception trace into log data

Data object is not included in failmail, but should still be logged.

Bug: T155757
Change-Id: Id2ac43afb19f36f8e28bdf5d6852e40814983d9e
---
M Core/Logging/LogEvent.php
1 file changed, 18 insertions(+), 10 deletions(-)

Approvals:
  jenkins-bot: Verified
  AndyRussG: Looks good to me, approved



diff --git a/Core/Logging/LogEvent.php b/Core/Logging/LogEvent.php
index 3d2e43b..0049a89 100644
--- a/Core/Logging/LogEvent.php
+++ b/Core/Logging/LogEvent.php
@@ -55,7 +55,7 @@
                                        $jdata = $data->toJson();
                                }
                                catch ( DataSerializationException $ex ) {
-          }
+                               }
                        } else {
                                $jdata = json_encode( $data );
                        }
@@ -69,6 +69,13 @@
                        $this->data = null;
                }
 
+               if ( $exception ) {
+                       if ( $this->data === null ) {
+                               $this->data = $exception->getTraceAsString();
+                       } else {
+                               $this->data .= $exception->getTraceAsString();
+                       }
+               }
                if ( !$timestamp ) {
                        $this->timestamp = time();
                        $this->datestring = date( 'c' );
@@ -82,10 +89,12 @@
        }
 
        /**
-        * Format the exception to be human readable
+        * Format the exception chain to be human readable
         *
-        * @return array The first element is the header, e.g. the type, 
location, line, and message. Following
-        * elements contain each individual stack trace line.
+        * @return array Each element is the type, location, line, and message
+        * of an exception in the causal chain, with the root cause listed 
first.
+        * We do not include the stack trace here, as it could include sensitive
+        * data.
         */
        public function getExceptionBlob() {
                $cex = $this->exception;
@@ -98,13 +107,12 @@
                do {
                        $descStr[] = get_class( $cex ) . 
"@{$cex->getFile()}:{$cex->getLine()} ({$cex->getMessage()})";
                        $cex = $cex->getPrevious();
+                       if ( $cex ) {
+                               $descStr[] = ' -> ';
+                       }
                } while ( $cex );
-               $descStr = implode( ' -> ', array_reverse( $descStr ) );
+               $descStr = array_reverse( $descStr );
 
-               // Get the stack trace
-               $stack = explode( "\n", $this->exception->getTraceAsString() );
-
-               array_unshift( $stack, $descStr );
-               return $stack;
+               return $descStr;
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/333041
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id2ac43afb19f36f8e28bdf5d6852e40814983d9e
Gerrit-PatchSet: 3
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to