From 711f436b2431ebf2845ee89a556ffde619212405 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 4 Jan 2022 16:19:58 +0100 Subject: [PATCH] Use finally to restore error handler after command runs --- src/Composer/Console/Application.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 9dce97fbe..c138e1e60 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -338,8 +338,6 @@ class Application extends BaseApplication $io->writeError('Memory usage: '.round(memory_get_usage() / 1024 / 1024, 2).'MiB (peak: '.round(memory_get_peak_usage() / 1024 / 1024, 2).'MiB), time: '.round(microtime(true) - $startTime, 2).'s'); } - restore_error_handler(); - return $result; } catch (ScriptExecutionException $e) { return (int) $e->getCode(); @@ -349,9 +347,9 @@ class Application extends BaseApplication $this->hintCommonErrors($e); - restore_error_handler(); - throw $e; + } finally { + restore_error_handler(); } }