Skip to content

Commit 3745d28

Browse files
committed
Fix(migrations) Handle transaction on PDO and PHPv8
1 parent f47a790 commit 3745d28

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

lib/Doctrine/Export.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ public function exportClasses(array $classes)
12211221
}
12221222
}
12231223

1224-
$connection->commit();
1224+
Doctrine_TransactionHelper::commitIfInTransaction($connection);
12251225
}
12261226
}
12271227

lib/Doctrine/Migration.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -335,24 +335,21 @@ public function migrate($to = null, $dryRun = false)
335335

336336
if ($dryRun) {
337337
return false;
338-
} else {
339-
$this->_throwErrorsException();
340-
}
341-
} else {
342-
if ($dryRun) {
343-
$this->_connection->rollback();
344-
if ($this->hasErrors()) {
345-
return false;
346-
} else {
347-
return $to;
348-
}
349-
} else {
350-
$this->_connection->commit();
351-
$this->setCurrentVersion($to);
352-
return $to;
353338
}
339+
340+
$this->_throwErrorsException();
341+
}
342+
343+
if ($dryRun) {
344+
$this->_connection->rollback();
345+
346+
return !$this->hasErrors();
354347
}
355-
return false;
348+
349+
Doctrine_TransactionHelper::commitIfInTransaction($this->_connection);
350+
$this->setCurrentVersion($to);
351+
352+
return true;
356353
}
357354

358355
/**
@@ -437,8 +434,9 @@ public function getMigrationClass($num)
437434
/**
438435
* Throw an exception with all the errors trigged during the migration
439436
*
440-
* @return void
441-
* @throws Doctrine_Migration_Exception $e
437+
* @throws Doctrine_Migration_Exception
438+
*
439+
* @return never
442440
*/
443441
protected function _throwErrorsException()
444442
{
@@ -559,4 +557,4 @@ protected function _createMigrationTable()
559557
return false;
560558
}
561559
}
562-
}
560+
}

0 commit comments

Comments
 (0)