From 63ce1c00712216f6c4d39f742e2afd49fbfd190e Mon Sep 17 00:00:00 2001 From: Volodya Kurshudyan <70023120+xurshudyan@users.noreply.github.com> Date: Tue, 23 May 2023 21:25:20 +0400 Subject: [PATCH] [10.x] Add error handling and ensure re-enabling of foreign key constraints (#47182) * Add error handling and ensure re-enabling of foreign key constraints * Return the result directly from the try block --------- Co-authored-by: Volodya Khurshudyan --- src/Illuminate/Database/Schema/Builder.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Database/Schema/Builder.php b/src/Illuminate/Database/Schema/Builder.php index 9f56957e7f8b..a38b526c9a33 100755 --- a/src/Illuminate/Database/Schema/Builder.php +++ b/src/Illuminate/Database/Schema/Builder.php @@ -421,11 +421,11 @@ public function withoutForeignKeyConstraints(Closure $callback) { $this->disableForeignKeyConstraints(); - $result = $callback(); - - $this->enableForeignKeyConstraints(); - - return $result; + try { + return $callback(); + } finally { + $this->enableForeignKeyConstraints(); + } } /**