Merge branch 'fix/#5796-catch-also-throwable-in-transactional-abstraction'
Close #5796
This commit is contained in:
commit
4bc29d1049
@ -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;
|
||||||
@ -28,6 +27,7 @@ use Doctrine\ORM\Query\ResultSetMapping;
|
|||||||
use Doctrine\ORM\Proxy\ProxyFactory;
|
use Doctrine\ORM\Proxy\ProxyFactory;
|
||||||
use Doctrine\ORM\Query\FilterCollection;
|
use Doctrine\ORM\Query\FilterCollection;
|
||||||
use Doctrine\Common\Util\ClassUtils;
|
use Doctrine\Common\Util\ClassUtils;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The EntityManager is the central access point to ORM functionality.
|
* The EntityManager is the central access point to ORM functionality.
|
||||||
@ -237,7 +237,7 @@ 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->close();
|
||||||
$this->conn->rollBack();
|
$this->conn->rollBack();
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ use Doctrine\DBAL\Connection;
|
|||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Doctrine\ORM\Query\AST;
|
use Doctrine\ORM\Query\AST;
|
||||||
use Doctrine\ORM\Utility\PersisterHelper;
|
use Doctrine\ORM\Utility\PersisterHelper;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL statements for bulk DQL DELETE statements on classes in
|
* Executes the SQL statements for bulk DQL DELETE statements on classes in
|
||||||
@ -129,7 +130,7 @@ 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);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ use Doctrine\DBAL\Types\Type;
|
|||||||
use Doctrine\ORM\Query\ParameterTypeInferer;
|
use Doctrine\ORM\Query\ParameterTypeInferer;
|
||||||
use Doctrine\ORM\Query\AST;
|
use Doctrine\ORM\Query\AST;
|
||||||
use Doctrine\ORM\Utility\PersisterHelper;
|
use Doctrine\ORM\Utility\PersisterHelper;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the SQL statements for bulk DQL UPDATE statements on classes in
|
* Executes the SQL statements for bulk DQL UPDATE statements on classes in
|
||||||
@ -188,7 +189,7 @@ 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);
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ use Symfony\Component\Console\Command\Command;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command to ensure that Doctrine is properly configured for a production environment.
|
* Command to ensure that Doctrine is properly configured for a production environment.
|
||||||
@ -72,7 +73,7 @@ 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>');
|
$output->writeln('<error>' . $e->getMessage() . '</error>');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -92,7 +92,7 @@ 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);
|
throw ToolsException::schemaToolFailure($sql, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -742,8 +742,8 @@ class SchemaTool
|
|||||||
foreach ($dropSchemaSql as $sql) {
|
foreach ($dropSchemaSql as $sql) {
|
||||||
try {
|
try {
|
||||||
$conn->executeQuery($sql);
|
$conn->executeQuery($sql);
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
|
// ignored
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
namespace Doctrine\ORM\Tools;
|
namespace Doctrine\ORM\Tools;
|
||||||
|
|
||||||
use Doctrine\ORM\ORMException;
|
use Doctrine\ORM\ORMException;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tools related Exceptions.
|
* Tools related Exceptions.
|
||||||
@ -28,13 +29,7 @@ use Doctrine\ORM\ORMException;
|
|||||||
*/
|
*/
|
||||||
class ToolsException extends ORMException
|
class ToolsException extends ORMException
|
||||||
{
|
{
|
||||||
/**
|
public static function schemaToolFailure(string $sql, Throwable $e) : self
|
||||||
* @param string $sql
|
|
||||||
* @param \Exception $e
|
|
||||||
*
|
|
||||||
* @return ToolsException
|
|
||||||
*/
|
|
||||||
public static function schemaToolFailure($sql, \Exception $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);
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,8 @@ use Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister;
|
|||||||
use Doctrine\ORM\Persisters\Entity\SingleTablePersister;
|
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 InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
use Throwable;
|
||||||
use UnexpectedValueException;
|
use UnexpectedValueException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -411,7 +411,7 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
$conn->commit();
|
$conn->commit();
|
||||||
} catch (Exception $e) {
|
} catch (Throwable $e) {
|
||||||
$this->em->close();
|
$this->em->close();
|
||||||
$conn->rollBack();
|
$conn->rollBack();
|
||||||
|
|
||||||
|
@ -232,6 +232,24 @@ class EntityManagerTest extends OrmTestCase
|
|||||||
EntityManager::create(1, $config);
|
EntityManager::create(1, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group #5796
|
||||||
|
*/
|
||||||
|
public function testTransactionalReThrowsThrowables()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->_em->transactional(function () {
|
||||||
|
(function (array $value) {
|
||||||
|
// this only serves as an IIFE that throws a `TypeError`
|
||||||
|
})(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
self::fail('TypeError expected to be thrown');
|
||||||
|
} catch (\TypeError $ignored) {
|
||||||
|
self::assertFalse($this->_em->isOpen());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group 6017
|
* @group 6017
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user