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

Change subject: CLI: Make sure we don't exit with 0 when an exception is 
encountered
......................................................................


CLI: Make sure we don't exit with 0 when an exception is encountered

I registered the additional shutdown function for CLI only
as it shouldn't have effect otherwise.

Bug: T177414
Change-Id: I440d294eef5e307743cfc7f5ab3b531e8c973873
---
M includes/exception/MWExceptionHandler.php
1 file changed, 20 insertions(+), 1 deletion(-)

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



diff --git a/includes/exception/MWExceptionHandler.php 
b/includes/exception/MWExceptionHandler.php
index a2ec391..9b59191 100644
--- a/includes/exception/MWExceptionHandler.php
+++ b/includes/exception/MWExceptionHandler.php
@@ -51,7 +51,7 @@
         * Install handlers with PHP.
         */
        public static function installHandler() {
-               set_exception_handler( 'MWExceptionHandler::handleException' );
+               set_exception_handler( 
'MWExceptionHandler::handleUncaughtException' );
                set_error_handler( 'MWExceptionHandler::handleError' );
 
                // Reserve 16k of memory so we can report OOM fatals
@@ -112,6 +112,25 @@
        }
 
        /**
+        * Callback to use with PHP's set_exception_handler.
+        *
+        * @since 1.31
+        * @param Exception|Throwable $e
+        */
+       public static function handleUncaughtException( $e ) {
+               self::handleException( $e );
+
+               // Make sure we don't claim success on exit for CLI scripts 
(T177414)
+               if ( PHP_SAPI === 'cli' ) {
+                       register_shutdown_function(
+                               function () {
+                                       exit( 255 );
+                               }
+                       );
+               }
+       }
+
+       /**
         * Exception handler which simulates the appropriate catch() handling:
         *
         *   try {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I440d294eef5e307743cfc7f5ab3b531e8c973873
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: ArielGlenn <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to