mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Infinite loops in TempDatabase (fixes #8902)
Ugly, but so is the original implementation that this works around (swallowing an exception to trigger functionality)
This commit is contained in:
parent
bcab982aa7
commit
052c5cbc38
@ -24,6 +24,13 @@ class TempDatabase
|
||||
*/
|
||||
protected $name = null;
|
||||
|
||||
/**
|
||||
* Workaround to avoid infinite loops.
|
||||
*
|
||||
* @var Exception
|
||||
*/
|
||||
private $skippedException = null;
|
||||
|
||||
/**
|
||||
* Optionally remove the test DB when the PHP process exits
|
||||
*
|
||||
@ -293,6 +300,13 @@ class TempDatabase
|
||||
try {
|
||||
$this->rebuildTables($extraDataObjects);
|
||||
} catch (DatabaseException $ex) {
|
||||
// Avoid infinite loops
|
||||
if ($this->skippedException && $this->skippedException->getMessage() == $ex->getMessage()) {
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$this->skippedException = $ex;
|
||||
|
||||
// In case of error during build force a hard reset
|
||||
// e.g. pgsql doesn't allow schema updates inside transactions
|
||||
$this->kill();
|
||||
|
Loading…
Reference in New Issue
Block a user