mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Catch \Throwable
in critical places
Added catch `\Throwable` to be compatible with PHP7. Added it in cases where object state needs to be kept consistent. Mainly on transactions but also some other places where some values are reset before exiting. Most of them could probably be refactored by using `finally` in 2.1, as that requires PHP 5.5. fixes #12619
This commit is contained in:
@ -336,7 +336,7 @@ try {
|
||||
|
||||
$transaction->commit();
|
||||
|
||||
} catch(\Exception $e) {
|
||||
} catch(\Exception $e) { // replace \Exception with \Throwable when you are using PHP 7
|
||||
|
||||
$transaction->rollBack();
|
||||
|
||||
@ -421,13 +421,13 @@ try {
|
||||
try {
|
||||
$db->createCommand($sql2)->execute();
|
||||
$innerTransaction->commit();
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Exception $e) { // replace \Exception with \Throwable when you are using PHP 7
|
||||
$innerTransaction->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$outerTransaction->commit();
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Exception $e) { // replace \Exception with \Throwable when you are using PHP 7
|
||||
$outerTransaction->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
@ -570,7 +570,7 @@ try {
|
||||
$db->createCommand("UPDATE user SET username='demo' WHERE id=1")->execute();
|
||||
|
||||
$transaction->commit();
|
||||
} catch(\Exception $e) {
|
||||
} catch(\Exception $e) { // replace \Exception with \Throwable when you are using PHP 7
|
||||
$transaction->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
Reference in New Issue
Block a user