Skip to content

Commit 40b149e

Browse files
authored
Fix 3376. When an update fails, updatedb is still exiting with 0. (#3673)
* Fix 3376. When an update fails, updatedb is still exiting with 0. * CS.
1 parent 92abb4d commit 40b149e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Commands/core/UpdateDBCommands.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,12 @@ public function updateDoOne($module, $number, $dependency_map, &$context)
191191
$this->logger()->notice("Update started: $function");
192192
$ret['results']['query'] = $function($context['sandbox']);
193193
$ret['results']['success'] = true;
194-
} // @TODO We may want to do different error handling for different exception
195-
// types, but for now we'll just print the message.
196-
catch (\Exception $e) {
194+
} catch (\Throwable $e) {
195+
// PHP 7 introduces Throwable, which covers both Error and Exception throwables.
196+
$ret['#abort'] = ['success' => false, 'query' => $e->getMessage()];
197+
$this->logger()->error($e->getMessage());
198+
} catch (\Exception $e) {
199+
// In order to be compatible with PHP 5 we also catch regular Exceptions.
197200
$ret['#abort'] = ['success' => false, 'query' => $e->getMessage()];
198201
$this->logger()->error($e->getMessage());
199202
}

0 commit comments

Comments
 (0)