Catch Throwable in PHP 7
This commit is contained in:
parent
8c7052c99c
commit
874a5e3547
@ -19,7 +19,6 @@
|
||||
|
||||
namespace Doctrine\ORM;
|
||||
|
||||
use Exception;
|
||||
use Doctrine\Common\EventManager;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
@ -237,7 +236,12 @@ use Doctrine\Common\Util\ClassUtils;
|
||||
$this->conn->commit();
|
||||
|
||||
return $return ?: true;
|
||||
} catch (Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
$this->close();
|
||||
$this->conn->rollBack();
|
||||
|
||||
throw $e;
|
||||
} catch (\Exception $e) { // PHP 5
|
||||
$this->close();
|
||||
$this->conn->rollBack();
|
||||
|
||||
|
@ -129,11 +129,15 @@ class MultiTableDeleteExecutor extends AbstractSqlExecutor
|
||||
foreach ($this->_sqlStatements as $sql) {
|
||||
$conn->executeUpdate($sql);
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
} catch (\Throwable $exception) {
|
||||
// FAILURE! Drop temporary table to avoid possible collisions
|
||||
$conn->executeUpdate($this->_dropTempTableSql);
|
||||
|
||||
// Re-throw exception
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) { // PHP 5
|
||||
$conn->executeUpdate($this->_dropTempTableSql);
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
|
@ -188,11 +188,15 @@ class MultiTableUpdateExecutor extends AbstractSqlExecutor
|
||||
|
||||
$conn->executeUpdate($statement, $paramValues, $paramTypes);
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
} catch (\Throwable $exception) {
|
||||
// FAILURE! Drop temporary table to avoid possible collisions
|
||||
$conn->executeUpdate($this->_dropTempTableSql);
|
||||
|
||||
// Re-throw exception
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) { // PHP 5
|
||||
$conn->executeUpdate($this->_dropTempTableSql);
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,11 @@ EOT
|
||||
if ($input->getOption('complete') !== null) {
|
||||
$em->getConnection()->connect();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
$output->writeln('<error>' . $e->getMessage() . '</error>');
|
||||
|
||||
return 1;
|
||||
} catch (\Exception $e) { // PHP 5
|
||||
$output->writeln('<error>' . $e->getMessage() . '</error>');
|
||||
|
||||
return 1;
|
||||
|
@ -92,7 +92,9 @@ class SchemaTool
|
||||
foreach ($createSchemaSql as $sql) {
|
||||
try {
|
||||
$conn->executeQuery($sql);
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
throw ToolsException::schemaToolFailure($sql, $e);
|
||||
} catch (\Exception $e) { // PHP 5
|
||||
throw ToolsException::schemaToolFailure($sql, $e);
|
||||
}
|
||||
}
|
||||
@ -742,7 +744,9 @@ class SchemaTool
|
||||
foreach ($dropSchemaSql as $sql) {
|
||||
try {
|
||||
$conn->executeQuery($sql);
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
} catch (\Exception $e) { // PHP 5
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -30,11 +30,11 @@ class ToolsException extends ORMException
|
||||
{
|
||||
/**
|
||||
* @param string $sql
|
||||
* @param \Exception $e
|
||||
* @param \Exception $e The original exception, or duck-typed Throwable in PHP 7.
|
||||
*
|
||||
* @return ToolsException
|
||||
*/
|
||||
public static function schemaToolFailure($sql, \Exception $e)
|
||||
public static function schemaToolFailure($sql, $e)
|
||||
{
|
||||
return new self("Schema-Tool failed with Error '" . $e->getMessage() . "' while executing DDL: " . $sql, "0", $e);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ use Doctrine\ORM\Persisters\Entity\SingleTablePersister;
|
||||
use Doctrine\ORM\Proxy\Proxy;
|
||||
use Doctrine\ORM\Utility\IdentifierFlattener;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use InvalidArgumentException;
|
||||
use UnexpectedValueException;
|
||||
|
||||
@ -411,7 +412,14 @@ class UnitOfWork implements PropertyChangedListener
|
||||
}
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
$this->em->close();
|
||||
$conn->rollBack();
|
||||
|
||||
$this->afterTransactionRolledBack();
|
||||
|
||||
throw $e;
|
||||
} catch (\Exception $e) { // PHP 5
|
||||
$this->em->close();
|
||||
$conn->rollBack();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user