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