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:
Carsten Brandt
2016-12-16 02:20:02 +01:00
parent 4496b3e799
commit a3b6dfbb7b
7 changed files with 49 additions and 18 deletions

View File

@ -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;
}