jenkins-bot has submitted this change and it was merged.

Change subject: Some cleanups to MWExceptionHandler::handleException
......................................................................


Some cleanups to MWExceptionHandler::handleException

* Do not bother with profiling data, which is just another
  thing that can go wrong.
* Catch DB rollback errors to avoid getting stuck in
  report() loops during network partitions.

Change-Id: I92293b2261c48cf49625ea14a51987e5619ab8d4
---
M includes/exception/MWExceptionHandler.php
1 file changed, 14 insertions(+), 12 deletions(-)

Approvals:
  Anomie: Looks good to me, but someone else must approve
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/exception/MWExceptionHandler.php 
b/includes/exception/MWExceptionHandler.php
index 7110361..0582b24 100644
--- a/includes/exception/MWExceptionHandler.php
+++ b/includes/exception/MWExceptionHandler.php
@@ -150,21 +150,23 @@
         * @since 1.25
         * @param Exception $e
         */
-       public static function handleException( $e ) {
-               global $wgFullyInitialised;
+       public static function handleException( Exception $e ) {
+               try {
+                       // Rollback DBs to avoid transaction notices. This may 
fail
+                       // to rollback some DB due to connection issues or 
exceptions.
+                       // However, any sane DB driver will rollback implicitly 
anyway.
+                       self::rollbackMasterChangesAndLog( $e );
+               } catch ( DBError $e2 ) {
+                       // If the DB is unreacheable, rollback() will throw an 
error
+                       // and the error report() method might need messages 
from the DB,
+                       // which would result in an exception loop. PHP may 
escalate such
+                       // errors to "Exception thrown without a stack frame" 
fatals, but
+                       // it's better to be explicit here.
+                       self::logException( $e2 );
+               }
 
-               self::rollbackMasterChangesAndLog( $e );
                self::logException( $e );
                self::report( $e );
-
-               // Final cleanup
-               if ( $wgFullyInitialised ) {
-                       try {
-                               // uses $wgRequest, hence the 
$wgFullyInitialised condition
-                               wfLogProfilingData();
-                       } catch ( Exception $e ) {
-                       }
-               }
 
                // Exit value should be nonzero for the benefit of shell jobs
                exit( 1 );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I92293b2261c48cf49625ea14a51987e5619ab8d4
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to